From 82ac39fd875176fe3a6d46f451a3b6977cd9b923 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sat, 27 Feb 2016 11:09:31 +0100 Subject: [PATCH] Factorize content checking --- test/test_content/test_content.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index af6dec57..dbf6926a 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -76,22 +76,22 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _clean_path(cls, elem): """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:] - elif isinstance(elem, songsection.SongSection): - return elem.render(None)[1:] + elif 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, tex.LaTeX): return files.path2posix(elem.filename) - elif isinstance(elem, setcounter.CounterSetter): - return elem.render(None)[1:] - else: raise Exception(elem)