mirror of https://github.com/patacrep/patacrep.git
oliverpool
9 years ago
committed by
GitHub
15 changed files with 169 additions and 20 deletions
@ -0,0 +1,2 @@ |
|||
!*.sxd |
|||
!*.sbx |
@ -0,0 +1,26 @@ |
|||
\begin{idxblock}{A} |
|||
\idxentry{ |
|||
\indexauthor{}{Aba} |
|||
}{ |
|||
\hyperlink{song1-4.2}{4} |
|||
} \idxentry{ |
|||
\indexauthor{}{Äbc} |
|||
}{ |
|||
\hyperlink{song1-2.2}{2} |
|||
} \idxentry{ |
|||
\indexauthor{}{Abd} |
|||
}{ |
|||
\hyperlink{song1-3.2}{3} |
|||
} |
|||
\end{idxblock} |
|||
\begin{idxblock}{J} |
|||
\idxentry{ |
|||
\indexauthor{}{Jack} |
|||
}{ |
|||
\hyperlink{song1-1.2}{1} |
|||
} \idxentry{ |
|||
\indexauthor{}{Johns} |
|||
}{ |
|||
\hyperlink{song1-1.2}{1} |
|||
} |
|||
\end{idxblock} |
@ -0,0 +1,19 @@ |
|||
AUTHOR INDEX DATA FILE |
|||
%ignore unknown |
|||
%after by |
|||
%sep and |
|||
Jack and Johns |
|||
1 |
|||
song1-1.2 |
|||
Äbc |
|||
2 |
|||
song1-2.2 |
|||
Abd |
|||
3 |
|||
song1-3.2 |
|||
Aba |
|||
4 |
|||
song1-4.2 |
|||
unknown |
|||
5 |
|||
song1-5.2 |
@ -0,0 +1,22 @@ |
|||
\begin{idxblock}{C} |
|||
\idxentry{ |
|||
\indextitle{}{Caa} |
|||
}{ |
|||
\hyperlink{song1-3.2}{3} |
|||
} \idxentry{ |
|||
\indextitle{}{Çab} |
|||
}{ |
|||
\hyperlink{song1-2.2}{2} |
|||
} \idxentry{ |
|||
\indextitle{}{Cac} |
|||
}{ |
|||
\hyperlink{song1-4.2}{4} |
|||
} |
|||
\end{idxblock} |
|||
\begin{idxblock}{M} |
|||
\idxentry{ |
|||
\indextitle{}{My song} |
|||
}{ |
|||
\hyperlink{song1-1.2}{1} |
|||
} |
|||
\end{idxblock} |
@ -0,0 +1,13 @@ |
|||
TITLE INDEX DATA FILE |
|||
My song |
|||
1 |
|||
song1-1.2 |
|||
Çab |
|||
2 |
|||
song1-2.2 |
|||
Caa |
|||
3 |
|||
song1-3.2 |
|||
Cac |
|||
4 |
|||
song1-4.2 |
@ -0,0 +1,46 @@ |
|||
"""Tests for the index generation.""" |
|||
|
|||
import codecs |
|||
import glob |
|||
import os |
|||
import unittest |
|||
|
|||
from patacrep.index import process_sxd |
|||
|
|||
from .. import dynamic # pylint: disable=unused-import |
|||
|
|||
|
|||
class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|||
"""Test of the index generation. |
|||
|
|||
For any given `foo.sxd`, it generates the index. |
|||
It controls that the generated file is equal to the one in `foo.sbx`. |
|||
""" |
|||
|
|||
@classmethod |
|||
def _iter_testmethods(cls): |
|||
"""Iterate over dynamically generated test methods""" |
|||
for source in sorted(glob.glob(os.path.join( |
|||
os.path.dirname(__file__), |
|||
'*.sxd', |
|||
))): |
|||
base = source[:-len(".sxd")] |
|||
yield ( |
|||
"test_index_{}".format(os.path.basename(base)), |
|||
cls._create_index_test(base), |
|||
) |
|||
|
|||
@classmethod |
|||
def _create_index_test(cls, base): |
|||
"""Return a function that tests that `foo.sxd` produces the sbx file""" |
|||
|
|||
def test_index(self): |
|||
"""Test that `foo.sxd` produces the correct sbx file""" |
|||
generated_index = process_sxd(base + ".sxd").entries_to_str() |
|||
with codecs.open(base + ".sbx", "r", "utf-8") as control_index: |
|||
self.assertEqual(control_index.read(), generated_index, ) |
|||
|
|||
test_index.__doc__ = ( |
|||
"Test that '{base}.sxd' produces the correct sbx file""" |
|||
).format(base=os.path.basename(base)) |
|||
return test_index |
Loading…
Reference in new issue