Browse Source

Factorize content checking

pull/208/head
Oliverpool 9 years ago
parent
commit
82ac39fd87
  1. 18
      test/test_content/test_content.py

18
test/test_content/test_content.py

@ -76,22 +76,22 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
@classmethod @classmethod
def _clean_path(cls, elem): def _clean_path(cls, elem):
"""Shorten the path relative to the `songs` directory""" """Shorten the path relative to the `songs` directory"""
if isinstance(elem, song.SongRenderer):
songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs')
return files.path2posix(files.relpath(elem.song.fullpath, songpath))
elif isinstance(elem, section.Section): latex_command_classes = (
section.Section,
songsection.SongSection,
setcounter.CounterSetter,
)
if isinstance(elem, latex_command_classes):
return elem.render(None)[1:] return elem.render(None)[1:]
elif isinstance(elem, songsection.SongSection): elif isinstance(elem, song.SongRenderer):
return elem.render(None)[1:] songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs')
return files.path2posix(files.relpath(elem.song.fullpath, songpath))
elif isinstance(elem, tex.LaTeX): elif isinstance(elem, tex.LaTeX):
return files.path2posix(elem.filename) return files.path2posix(elem.filename)
elif isinstance(elem, setcounter.CounterSetter):
return elem.render(None)[1:]
else: else:
raise Exception(elem) raise Exception(elem)

Loading…
Cancel
Save