From 24d49cb29ef17b18fcc430ac9a8fd7bfcf4eb8a4 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 15 Sep 2015 22:23:00 +0200 Subject: [PATCH] [test] Moved tests to their own directory --- patacrep/files.py | 25 ++++++++----- patacrep/songs/chordpro/test/__init__.py | 1 - setup.py | 4 +- patacrep/test.py => test/__init__.py | 18 +++------ .../test => test/test_chordpro}/00.sgc | 0 .../test => test/test_chordpro}/00.source | 0 .../test => test/test_chordpro}/00.tex | 0 .../test => test/test_chordpro}/01.sgc | 0 .../test => test/test_chordpro}/01.source | 0 .../test => test/test_chordpro}/01.tex | 0 .../test => test/test_chordpro}/02.sgc | 0 .../test => test/test_chordpro}/02.source | 0 .../test => test/test_chordpro}/02.tex | 0 .../test => test/test_chordpro}/03.sgc | 0 .../test => test/test_chordpro}/03.source | 0 .../test => test/test_chordpro}/03.tex | 0 .../test => test/test_chordpro}/04.sgc | 0 .../test => test/test_chordpro}/04.source | 0 .../test => test/test_chordpro}/04.tex | 0 .../test => test/test_chordpro}/05.sgc | 0 .../test => test/test_chordpro}/05.source | 0 .../test => test/test_chordpro}/05.tex | 0 .../test => test/test_chordpro}/06.sgc | 0 .../test => test/test_chordpro}/06.source | 0 .../test => test/test_chordpro}/06.tex | 0 .../test => test/test_chordpro}/07.sgc | 0 .../test => test/test_chordpro}/07.source | 0 .../test => test/test_chordpro}/07.tex | 0 .../test => test/test_chordpro}/08.sgc | 0 .../test => test/test_chordpro}/08.source | 0 .../test => test/test_chordpro}/08.tex | 0 .../test => test/test_chordpro}/09.sgc | 0 .../test => test/test_chordpro}/09.source | 0 .../test => test/test_chordpro}/09.tex | 0 .../test => test/test_chordpro}/10.sgc | 0 .../test => test/test_chordpro}/10.source | 0 .../test => test/test_chordpro}/10.tex | 0 .../test => test/test_chordpro}/11.sgc | 0 .../test => test/test_chordpro}/11.source | 0 .../test => test/test_chordpro}/11.tex | 0 .../test => test/test_chordpro}/12.sgc | 0 .../test => test/test_chordpro}/12.source | 0 .../test => test/test_chordpro}/12.tex | 0 .../test => test/test_chordpro}/13.sgc | 0 .../test => test/test_chordpro}/13.source | 0 .../test => test/test_chordpro}/13.tex | 0 .../test => test/test_chordpro}/21.sgc | 0 .../test => test/test_chordpro}/21.source | 0 .../test => test/test_chordpro}/21.tex | 0 .../test => test/test_chordpro}/22.sgc | 0 .../test => test/test_chordpro}/22.source | 0 .../test => test/test_chordpro}/22.tex | 0 .../test => test/test_chordpro}/23.sgc | 0 .../test => test/test_chordpro}/23.source | 0 .../test => test/test_chordpro}/23.tex | 0 .../test => test/test_chordpro}/24.sgc | 0 .../test => test/test_chordpro}/24.source | 0 .../test => test/test_chordpro}/24.tex | 0 .../test => test/test_chordpro}/25.sgc | 0 .../test => test/test_chordpro}/25.source | 0 .../test => test/test_chordpro}/25.tex | 0 .../test => test/test_chordpro}/26.sgc | 0 .../test => test/test_chordpro}/26.source | 0 .../test => test/test_chordpro}/26.tex | 0 .../test => test/test_chordpro}/27.sgc | 0 .../test => test/test_chordpro}/27.source | 0 .../test => test/test_chordpro}/27.tex | 0 .../test => test/test_chordpro}/28.sgc | 0 .../test => test/test_chordpro}/28.source | 0 .../test => test/test_chordpro}/28.tex | 0 .../test => test/test_chordpro}/29.sgc | 0 .../test => test/test_chordpro}/29.source | 0 .../test => test/test_chordpro}/29.tex | 0 test/test_chordpro/__init__.py | 0 .../test_chordpro}/author_names.sgc | 0 .../test_chordpro}/author_names.source | 0 .../test_chordpro}/author_names.tex | 0 .../test => test/test_chordpro}/chords.sgc | 0 .../test => test/test_chordpro}/chords.source | 0 .../test => test/test_chordpro}/chords.tex | 0 .../test_chordpro}/customchords.sgc | 0 .../test_chordpro}/customchords.source | 0 .../test_chordpro}/customchords.tex | 0 .../test_chordpro}/greensleeves.sgc | 0 .../test_chordpro}/greensleeves.source | 0 .../test_chordpro}/greensleeves.tex | 0 .../test_chordpro}/invalid_chord.sgc | 0 .../test_chordpro}/invalid_chord.source | 0 .../test_chordpro}/invalid_chord.tex | 0 .../test_chordpro}/invalid_customchord.sgc | 0 .../test_chordpro}/invalid_customchord.source | 0 .../test_chordpro}/invalid_customchord.tex | 0 .../test => test/test_chordpro}/metadata.sgc | 0 .../test_chordpro}/metadata.source | 0 .../test => test/test_chordpro}/metadata.tex | 0 .../test_chordpro}/test_parser.py | 3 +- test/test_doctest.py | 37 +++++++++++++++++++ tox.ini | 2 +- 98 files changed, 64 insertions(+), 26 deletions(-) delete mode 100644 patacrep/songs/chordpro/test/__init__.py rename patacrep/test.py => test/__init__.py (51%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/00.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/00.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/00.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/01.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/01.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/01.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/02.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/02.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/02.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/03.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/03.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/03.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/04.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/04.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/04.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/05.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/05.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/05.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/06.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/06.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/06.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/07.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/07.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/07.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/08.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/08.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/08.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/09.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/09.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/09.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/10.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/10.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/10.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/11.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/11.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/11.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/12.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/12.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/12.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/13.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/13.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/13.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/21.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/21.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/21.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/22.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/22.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/22.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/23.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/23.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/23.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/24.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/24.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/24.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/25.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/25.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/25.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/26.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/26.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/26.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/27.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/27.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/27.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/28.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/28.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/28.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/29.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/29.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/29.tex (100%) create mode 100644 test/test_chordpro/__init__.py rename {patacrep/songs/chordpro/test => test/test_chordpro}/author_names.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/author_names.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/author_names.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/chords.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/chords.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/chords.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/customchords.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/customchords.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/customchords.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/greensleeves.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/greensleeves.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/greensleeves.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/invalid_chord.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/invalid_chord.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/invalid_chord.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/invalid_customchord.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/invalid_customchord.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/invalid_customchord.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/metadata.sgc (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/metadata.source (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/metadata.tex (100%) rename {patacrep/songs/chordpro/test => test/test_chordpro}/test_parser.py (97%) create mode 100644 test/test_doctest.py diff --git a/patacrep/files.py b/patacrep/files.py index f58e9356..e77c3ab2 100644 --- a/patacrep/files.py +++ b/patacrep/files.py @@ -71,6 +71,21 @@ def chdir(path): else: yield +def iter_modules(path, prefix): + """Iterate over modules located in list of `path`. + + Prefix is a prefix appended to all module names. + """ + for module_finder, name, __is_pkg in pkgutil.walk_packages(path, prefix): + if name in sys.modules: + yield sys.modules[name] + else: + try: + yield module_finder.find_spec(name).loader.load_module() + except ImportError as error: + LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error))) + continue + def load_plugins(datadirs, root_modules, keyword): """Load all plugins, and return a dictionary of those plugins. @@ -101,18 +116,10 @@ def load_plugins(datadirs, root_modules, keyword): for path in sys.path ] - for module_finder, name, __is_pkg in pkgutil.walk_packages( + for module in iter_modules( datadir_path + sys_path, prefix="patacrep.{}.".format(".".join(root_modules)) ): - if name in sys.modules: - module = sys.modules[name] - else: - try: - module = module_finder.find_spec(name).loader.load_module() - except ImportError as error: - LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error))) - continue if hasattr(module, keyword): for (key, value) in getattr(module, keyword).items(): if key in plugins: diff --git a/patacrep/songs/chordpro/test/__init__.py b/patacrep/songs/chordpro/test/__init__.py deleted file mode 100644 index b73d2af8..00000000 --- a/patacrep/songs/chordpro/test/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Test for chordpro parser""" diff --git a/setup.py b/setup.py index 5a315fbd..f9977913 100755 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( author='The Songbook team', author_email='crep@team-on-fire.com', url='https://github.com/patacrep/patacrep', - packages=find_packages(), + packages=find_packages(exclude=["test*"]), license="GPLv2 or any later version", install_requires=[ "unidecode", "jinja2", "chardet", "ply", @@ -39,6 +39,6 @@ setup( "Topic :: Utilities", ], platforms=["GNU/Linux", "Windows", "MacOsX"], - test_suite="patacrep.test.suite", + test_suite="test.suite", long_description = open("README.rst", "r").read(), ) diff --git a/patacrep/test.py b/test/__init__.py similarity index 51% rename from patacrep/test.py rename to test/__init__.py index 1a1eaae4..aa4a5a18 100644 --- a/patacrep/test.py +++ b/test/__init__.py @@ -16,20 +16,14 @@ def disable_logging(): logging.disable(logging.NOTSET) def suite(): - """Return a TestSuite object, to test whole `patacrep` package. - - Both unittest and doctest are tested. + """Return a :class:`TestSuite` object, testing all module :mod:`patacrep`. """ test_loader = unittest.defaultTestLoader - return test_loader.discover(os.path.dirname(__file__)) - -def load_tests(__loader, tests, __pattern): - """Load tests (unittests and doctests).""" - # Loading doctests - tests.addTests(doctest.DocTestSuite(patacrep)) - - # Unittests are loaded by default - return tests + return test_loader.discover( + os.path.abspath(os.path.dirname(__file__)), + pattern="*.py", + top_level_dir=os.path.abspath(os.path.join(patacrep.__path__[0], "..")), + ) if __name__ == "__main__": unittest.TextTestRunner().run(suite()) diff --git a/patacrep/songs/chordpro/test/00.sgc b/test/test_chordpro/00.sgc similarity index 100% rename from patacrep/songs/chordpro/test/00.sgc rename to test/test_chordpro/00.sgc diff --git a/patacrep/songs/chordpro/test/00.source b/test/test_chordpro/00.source similarity index 100% rename from patacrep/songs/chordpro/test/00.source rename to test/test_chordpro/00.source diff --git a/patacrep/songs/chordpro/test/00.tex b/test/test_chordpro/00.tex similarity index 100% rename from patacrep/songs/chordpro/test/00.tex rename to test/test_chordpro/00.tex diff --git a/patacrep/songs/chordpro/test/01.sgc b/test/test_chordpro/01.sgc similarity index 100% rename from patacrep/songs/chordpro/test/01.sgc rename to test/test_chordpro/01.sgc diff --git a/patacrep/songs/chordpro/test/01.source b/test/test_chordpro/01.source similarity index 100% rename from patacrep/songs/chordpro/test/01.source rename to test/test_chordpro/01.source diff --git a/patacrep/songs/chordpro/test/01.tex b/test/test_chordpro/01.tex similarity index 100% rename from patacrep/songs/chordpro/test/01.tex rename to test/test_chordpro/01.tex diff --git a/patacrep/songs/chordpro/test/02.sgc b/test/test_chordpro/02.sgc similarity index 100% rename from patacrep/songs/chordpro/test/02.sgc rename to test/test_chordpro/02.sgc diff --git a/patacrep/songs/chordpro/test/02.source b/test/test_chordpro/02.source similarity index 100% rename from patacrep/songs/chordpro/test/02.source rename to test/test_chordpro/02.source diff --git a/patacrep/songs/chordpro/test/02.tex b/test/test_chordpro/02.tex similarity index 100% rename from patacrep/songs/chordpro/test/02.tex rename to test/test_chordpro/02.tex diff --git a/patacrep/songs/chordpro/test/03.sgc b/test/test_chordpro/03.sgc similarity index 100% rename from patacrep/songs/chordpro/test/03.sgc rename to test/test_chordpro/03.sgc diff --git a/patacrep/songs/chordpro/test/03.source b/test/test_chordpro/03.source similarity index 100% rename from patacrep/songs/chordpro/test/03.source rename to test/test_chordpro/03.source diff --git a/patacrep/songs/chordpro/test/03.tex b/test/test_chordpro/03.tex similarity index 100% rename from patacrep/songs/chordpro/test/03.tex rename to test/test_chordpro/03.tex diff --git a/patacrep/songs/chordpro/test/04.sgc b/test/test_chordpro/04.sgc similarity index 100% rename from patacrep/songs/chordpro/test/04.sgc rename to test/test_chordpro/04.sgc diff --git a/patacrep/songs/chordpro/test/04.source b/test/test_chordpro/04.source similarity index 100% rename from patacrep/songs/chordpro/test/04.source rename to test/test_chordpro/04.source diff --git a/patacrep/songs/chordpro/test/04.tex b/test/test_chordpro/04.tex similarity index 100% rename from patacrep/songs/chordpro/test/04.tex rename to test/test_chordpro/04.tex diff --git a/patacrep/songs/chordpro/test/05.sgc b/test/test_chordpro/05.sgc similarity index 100% rename from patacrep/songs/chordpro/test/05.sgc rename to test/test_chordpro/05.sgc diff --git a/patacrep/songs/chordpro/test/05.source b/test/test_chordpro/05.source similarity index 100% rename from patacrep/songs/chordpro/test/05.source rename to test/test_chordpro/05.source diff --git a/patacrep/songs/chordpro/test/05.tex b/test/test_chordpro/05.tex similarity index 100% rename from patacrep/songs/chordpro/test/05.tex rename to test/test_chordpro/05.tex diff --git a/patacrep/songs/chordpro/test/06.sgc b/test/test_chordpro/06.sgc similarity index 100% rename from patacrep/songs/chordpro/test/06.sgc rename to test/test_chordpro/06.sgc diff --git a/patacrep/songs/chordpro/test/06.source b/test/test_chordpro/06.source similarity index 100% rename from patacrep/songs/chordpro/test/06.source rename to test/test_chordpro/06.source diff --git a/patacrep/songs/chordpro/test/06.tex b/test/test_chordpro/06.tex similarity index 100% rename from patacrep/songs/chordpro/test/06.tex rename to test/test_chordpro/06.tex diff --git a/patacrep/songs/chordpro/test/07.sgc b/test/test_chordpro/07.sgc similarity index 100% rename from patacrep/songs/chordpro/test/07.sgc rename to test/test_chordpro/07.sgc diff --git a/patacrep/songs/chordpro/test/07.source b/test/test_chordpro/07.source similarity index 100% rename from patacrep/songs/chordpro/test/07.source rename to test/test_chordpro/07.source diff --git a/patacrep/songs/chordpro/test/07.tex b/test/test_chordpro/07.tex similarity index 100% rename from patacrep/songs/chordpro/test/07.tex rename to test/test_chordpro/07.tex diff --git a/patacrep/songs/chordpro/test/08.sgc b/test/test_chordpro/08.sgc similarity index 100% rename from patacrep/songs/chordpro/test/08.sgc rename to test/test_chordpro/08.sgc diff --git a/patacrep/songs/chordpro/test/08.source b/test/test_chordpro/08.source similarity index 100% rename from patacrep/songs/chordpro/test/08.source rename to test/test_chordpro/08.source diff --git a/patacrep/songs/chordpro/test/08.tex b/test/test_chordpro/08.tex similarity index 100% rename from patacrep/songs/chordpro/test/08.tex rename to test/test_chordpro/08.tex diff --git a/patacrep/songs/chordpro/test/09.sgc b/test/test_chordpro/09.sgc similarity index 100% rename from patacrep/songs/chordpro/test/09.sgc rename to test/test_chordpro/09.sgc diff --git a/patacrep/songs/chordpro/test/09.source b/test/test_chordpro/09.source similarity index 100% rename from patacrep/songs/chordpro/test/09.source rename to test/test_chordpro/09.source diff --git a/patacrep/songs/chordpro/test/09.tex b/test/test_chordpro/09.tex similarity index 100% rename from patacrep/songs/chordpro/test/09.tex rename to test/test_chordpro/09.tex diff --git a/patacrep/songs/chordpro/test/10.sgc b/test/test_chordpro/10.sgc similarity index 100% rename from patacrep/songs/chordpro/test/10.sgc rename to test/test_chordpro/10.sgc diff --git a/patacrep/songs/chordpro/test/10.source b/test/test_chordpro/10.source similarity index 100% rename from patacrep/songs/chordpro/test/10.source rename to test/test_chordpro/10.source diff --git a/patacrep/songs/chordpro/test/10.tex b/test/test_chordpro/10.tex similarity index 100% rename from patacrep/songs/chordpro/test/10.tex rename to test/test_chordpro/10.tex diff --git a/patacrep/songs/chordpro/test/11.sgc b/test/test_chordpro/11.sgc similarity index 100% rename from patacrep/songs/chordpro/test/11.sgc rename to test/test_chordpro/11.sgc diff --git a/patacrep/songs/chordpro/test/11.source b/test/test_chordpro/11.source similarity index 100% rename from patacrep/songs/chordpro/test/11.source rename to test/test_chordpro/11.source diff --git a/patacrep/songs/chordpro/test/11.tex b/test/test_chordpro/11.tex similarity index 100% rename from patacrep/songs/chordpro/test/11.tex rename to test/test_chordpro/11.tex diff --git a/patacrep/songs/chordpro/test/12.sgc b/test/test_chordpro/12.sgc similarity index 100% rename from patacrep/songs/chordpro/test/12.sgc rename to test/test_chordpro/12.sgc diff --git a/patacrep/songs/chordpro/test/12.source b/test/test_chordpro/12.source similarity index 100% rename from patacrep/songs/chordpro/test/12.source rename to test/test_chordpro/12.source diff --git a/patacrep/songs/chordpro/test/12.tex b/test/test_chordpro/12.tex similarity index 100% rename from patacrep/songs/chordpro/test/12.tex rename to test/test_chordpro/12.tex diff --git a/patacrep/songs/chordpro/test/13.sgc b/test/test_chordpro/13.sgc similarity index 100% rename from patacrep/songs/chordpro/test/13.sgc rename to test/test_chordpro/13.sgc diff --git a/patacrep/songs/chordpro/test/13.source b/test/test_chordpro/13.source similarity index 100% rename from patacrep/songs/chordpro/test/13.source rename to test/test_chordpro/13.source diff --git a/patacrep/songs/chordpro/test/13.tex b/test/test_chordpro/13.tex similarity index 100% rename from patacrep/songs/chordpro/test/13.tex rename to test/test_chordpro/13.tex diff --git a/patacrep/songs/chordpro/test/21.sgc b/test/test_chordpro/21.sgc similarity index 100% rename from patacrep/songs/chordpro/test/21.sgc rename to test/test_chordpro/21.sgc diff --git a/patacrep/songs/chordpro/test/21.source b/test/test_chordpro/21.source similarity index 100% rename from patacrep/songs/chordpro/test/21.source rename to test/test_chordpro/21.source diff --git a/patacrep/songs/chordpro/test/21.tex b/test/test_chordpro/21.tex similarity index 100% rename from patacrep/songs/chordpro/test/21.tex rename to test/test_chordpro/21.tex diff --git a/patacrep/songs/chordpro/test/22.sgc b/test/test_chordpro/22.sgc similarity index 100% rename from patacrep/songs/chordpro/test/22.sgc rename to test/test_chordpro/22.sgc diff --git a/patacrep/songs/chordpro/test/22.source b/test/test_chordpro/22.source similarity index 100% rename from patacrep/songs/chordpro/test/22.source rename to test/test_chordpro/22.source diff --git a/patacrep/songs/chordpro/test/22.tex b/test/test_chordpro/22.tex similarity index 100% rename from patacrep/songs/chordpro/test/22.tex rename to test/test_chordpro/22.tex diff --git a/patacrep/songs/chordpro/test/23.sgc b/test/test_chordpro/23.sgc similarity index 100% rename from patacrep/songs/chordpro/test/23.sgc rename to test/test_chordpro/23.sgc diff --git a/patacrep/songs/chordpro/test/23.source b/test/test_chordpro/23.source similarity index 100% rename from patacrep/songs/chordpro/test/23.source rename to test/test_chordpro/23.source diff --git a/patacrep/songs/chordpro/test/23.tex b/test/test_chordpro/23.tex similarity index 100% rename from patacrep/songs/chordpro/test/23.tex rename to test/test_chordpro/23.tex diff --git a/patacrep/songs/chordpro/test/24.sgc b/test/test_chordpro/24.sgc similarity index 100% rename from patacrep/songs/chordpro/test/24.sgc rename to test/test_chordpro/24.sgc diff --git a/patacrep/songs/chordpro/test/24.source b/test/test_chordpro/24.source similarity index 100% rename from patacrep/songs/chordpro/test/24.source rename to test/test_chordpro/24.source diff --git a/patacrep/songs/chordpro/test/24.tex b/test/test_chordpro/24.tex similarity index 100% rename from patacrep/songs/chordpro/test/24.tex rename to test/test_chordpro/24.tex diff --git a/patacrep/songs/chordpro/test/25.sgc b/test/test_chordpro/25.sgc similarity index 100% rename from patacrep/songs/chordpro/test/25.sgc rename to test/test_chordpro/25.sgc diff --git a/patacrep/songs/chordpro/test/25.source b/test/test_chordpro/25.source similarity index 100% rename from patacrep/songs/chordpro/test/25.source rename to test/test_chordpro/25.source diff --git a/patacrep/songs/chordpro/test/25.tex b/test/test_chordpro/25.tex similarity index 100% rename from patacrep/songs/chordpro/test/25.tex rename to test/test_chordpro/25.tex diff --git a/patacrep/songs/chordpro/test/26.sgc b/test/test_chordpro/26.sgc similarity index 100% rename from patacrep/songs/chordpro/test/26.sgc rename to test/test_chordpro/26.sgc diff --git a/patacrep/songs/chordpro/test/26.source b/test/test_chordpro/26.source similarity index 100% rename from patacrep/songs/chordpro/test/26.source rename to test/test_chordpro/26.source diff --git a/patacrep/songs/chordpro/test/26.tex b/test/test_chordpro/26.tex similarity index 100% rename from patacrep/songs/chordpro/test/26.tex rename to test/test_chordpro/26.tex diff --git a/patacrep/songs/chordpro/test/27.sgc b/test/test_chordpro/27.sgc similarity index 100% rename from patacrep/songs/chordpro/test/27.sgc rename to test/test_chordpro/27.sgc diff --git a/patacrep/songs/chordpro/test/27.source b/test/test_chordpro/27.source similarity index 100% rename from patacrep/songs/chordpro/test/27.source rename to test/test_chordpro/27.source diff --git a/patacrep/songs/chordpro/test/27.tex b/test/test_chordpro/27.tex similarity index 100% rename from patacrep/songs/chordpro/test/27.tex rename to test/test_chordpro/27.tex diff --git a/patacrep/songs/chordpro/test/28.sgc b/test/test_chordpro/28.sgc similarity index 100% rename from patacrep/songs/chordpro/test/28.sgc rename to test/test_chordpro/28.sgc diff --git a/patacrep/songs/chordpro/test/28.source b/test/test_chordpro/28.source similarity index 100% rename from patacrep/songs/chordpro/test/28.source rename to test/test_chordpro/28.source diff --git a/patacrep/songs/chordpro/test/28.tex b/test/test_chordpro/28.tex similarity index 100% rename from patacrep/songs/chordpro/test/28.tex rename to test/test_chordpro/28.tex diff --git a/patacrep/songs/chordpro/test/29.sgc b/test/test_chordpro/29.sgc similarity index 100% rename from patacrep/songs/chordpro/test/29.sgc rename to test/test_chordpro/29.sgc diff --git a/patacrep/songs/chordpro/test/29.source b/test/test_chordpro/29.source similarity index 100% rename from patacrep/songs/chordpro/test/29.source rename to test/test_chordpro/29.source diff --git a/patacrep/songs/chordpro/test/29.tex b/test/test_chordpro/29.tex similarity index 100% rename from patacrep/songs/chordpro/test/29.tex rename to test/test_chordpro/29.tex diff --git a/test/test_chordpro/__init__.py b/test/test_chordpro/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/patacrep/songs/chordpro/test/author_names.sgc b/test/test_chordpro/author_names.sgc similarity index 100% rename from patacrep/songs/chordpro/test/author_names.sgc rename to test/test_chordpro/author_names.sgc diff --git a/patacrep/songs/chordpro/test/author_names.source b/test/test_chordpro/author_names.source similarity index 100% rename from patacrep/songs/chordpro/test/author_names.source rename to test/test_chordpro/author_names.source diff --git a/patacrep/songs/chordpro/test/author_names.tex b/test/test_chordpro/author_names.tex similarity index 100% rename from patacrep/songs/chordpro/test/author_names.tex rename to test/test_chordpro/author_names.tex diff --git a/patacrep/songs/chordpro/test/chords.sgc b/test/test_chordpro/chords.sgc similarity index 100% rename from patacrep/songs/chordpro/test/chords.sgc rename to test/test_chordpro/chords.sgc diff --git a/patacrep/songs/chordpro/test/chords.source b/test/test_chordpro/chords.source similarity index 100% rename from patacrep/songs/chordpro/test/chords.source rename to test/test_chordpro/chords.source diff --git a/patacrep/songs/chordpro/test/chords.tex b/test/test_chordpro/chords.tex similarity index 100% rename from patacrep/songs/chordpro/test/chords.tex rename to test/test_chordpro/chords.tex diff --git a/patacrep/songs/chordpro/test/customchords.sgc b/test/test_chordpro/customchords.sgc similarity index 100% rename from patacrep/songs/chordpro/test/customchords.sgc rename to test/test_chordpro/customchords.sgc diff --git a/patacrep/songs/chordpro/test/customchords.source b/test/test_chordpro/customchords.source similarity index 100% rename from patacrep/songs/chordpro/test/customchords.source rename to test/test_chordpro/customchords.source diff --git a/patacrep/songs/chordpro/test/customchords.tex b/test/test_chordpro/customchords.tex similarity index 100% rename from patacrep/songs/chordpro/test/customchords.tex rename to test/test_chordpro/customchords.tex diff --git a/patacrep/songs/chordpro/test/greensleeves.sgc b/test/test_chordpro/greensleeves.sgc similarity index 100% rename from patacrep/songs/chordpro/test/greensleeves.sgc rename to test/test_chordpro/greensleeves.sgc diff --git a/patacrep/songs/chordpro/test/greensleeves.source b/test/test_chordpro/greensleeves.source similarity index 100% rename from patacrep/songs/chordpro/test/greensleeves.source rename to test/test_chordpro/greensleeves.source diff --git a/patacrep/songs/chordpro/test/greensleeves.tex b/test/test_chordpro/greensleeves.tex similarity index 100% rename from patacrep/songs/chordpro/test/greensleeves.tex rename to test/test_chordpro/greensleeves.tex diff --git a/patacrep/songs/chordpro/test/invalid_chord.sgc b/test/test_chordpro/invalid_chord.sgc similarity index 100% rename from patacrep/songs/chordpro/test/invalid_chord.sgc rename to test/test_chordpro/invalid_chord.sgc diff --git a/patacrep/songs/chordpro/test/invalid_chord.source b/test/test_chordpro/invalid_chord.source similarity index 100% rename from patacrep/songs/chordpro/test/invalid_chord.source rename to test/test_chordpro/invalid_chord.source diff --git a/patacrep/songs/chordpro/test/invalid_chord.tex b/test/test_chordpro/invalid_chord.tex similarity index 100% rename from patacrep/songs/chordpro/test/invalid_chord.tex rename to test/test_chordpro/invalid_chord.tex diff --git a/patacrep/songs/chordpro/test/invalid_customchord.sgc b/test/test_chordpro/invalid_customchord.sgc similarity index 100% rename from patacrep/songs/chordpro/test/invalid_customchord.sgc rename to test/test_chordpro/invalid_customchord.sgc diff --git a/patacrep/songs/chordpro/test/invalid_customchord.source b/test/test_chordpro/invalid_customchord.source similarity index 100% rename from patacrep/songs/chordpro/test/invalid_customchord.source rename to test/test_chordpro/invalid_customchord.source diff --git a/patacrep/songs/chordpro/test/invalid_customchord.tex b/test/test_chordpro/invalid_customchord.tex similarity index 100% rename from patacrep/songs/chordpro/test/invalid_customchord.tex rename to test/test_chordpro/invalid_customchord.tex diff --git a/patacrep/songs/chordpro/test/metadata.sgc b/test/test_chordpro/metadata.sgc similarity index 100% rename from patacrep/songs/chordpro/test/metadata.sgc rename to test/test_chordpro/metadata.sgc diff --git a/patacrep/songs/chordpro/test/metadata.source b/test/test_chordpro/metadata.source similarity index 100% rename from patacrep/songs/chordpro/test/metadata.source rename to test/test_chordpro/metadata.source diff --git a/patacrep/songs/chordpro/test/metadata.tex b/test/test_chordpro/metadata.tex similarity index 100% rename from patacrep/songs/chordpro/test/metadata.tex rename to test/test_chordpro/metadata.tex diff --git a/patacrep/songs/chordpro/test/test_parser.py b/test/test_chordpro/test_parser.py similarity index 97% rename from patacrep/songs/chordpro/test/test_parser.py rename to test/test_chordpro/test_parser.py index 9633df1f..2bdd15aa 100644 --- a/patacrep/songs/chordpro/test/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -8,7 +8,8 @@ import unittest from patacrep.build import DEFAULT_CONFIG from patacrep.songs.chordpro import ChordproSong -from patacrep.test import disable_logging + +from .. import disable_logging LANGUAGES = { 'tex': 'latex', diff --git a/test/test_doctest.py b/test/test_doctest.py new file mode 100644 index 00000000..98175716 --- /dev/null +++ b/test/test_doctest.py @@ -0,0 +1,37 @@ +#!/usr/bin python + +# Copyright 2015 Louis Paternault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""Tests""" + +import doctest + +import patacrep +from patacrep import files + +def load_tests(__loader, tests, __pattern): + """Load tests (doctests). + """ + # Loading doctests + tests.addTests(doctest.DocTestSuite(patacrep)) + for module in files.iter_modules(patacrep.__path__, "{}.".format(patacrep.__name__)): + try: + tests.addTests(doctest.DocTestSuite(module)) + except ValueError: + # No docstring, or no doctests in the docstrings + continue + + return tests diff --git a/tox.ini b/tox.ini index 60871634..aa6c7c00 100644 --- a/tox.ini +++ b/tox.ini @@ -12,4 +12,4 @@ deps = [testenv:lint] basepython=python3.4 deps=pylint -commands=pylint patacrep --rcfile=pylintrc +commands=pylint patacrep test --rcfile=pylintrc