Browse Source

[test] Moved tests to their own directory

pull/90/head
Louis 9 years ago
parent
commit
24d49cb29e
  1. 25
      patacrep/files.py
  2. 1
      patacrep/songs/chordpro/test/__init__.py
  3. 4
      setup.py
  4. 18
      test/__init__.py
  5. 0
      test/test_chordpro/00.sgc
  6. 0
      test/test_chordpro/00.source
  7. 0
      test/test_chordpro/00.tex
  8. 0
      test/test_chordpro/01.sgc
  9. 0
      test/test_chordpro/01.source
  10. 0
      test/test_chordpro/01.tex
  11. 0
      test/test_chordpro/02.sgc
  12. 0
      test/test_chordpro/02.source
  13. 0
      test/test_chordpro/02.tex
  14. 0
      test/test_chordpro/03.sgc
  15. 0
      test/test_chordpro/03.source
  16. 0
      test/test_chordpro/03.tex
  17. 0
      test/test_chordpro/04.sgc
  18. 0
      test/test_chordpro/04.source
  19. 0
      test/test_chordpro/04.tex
  20. 0
      test/test_chordpro/05.sgc
  21. 0
      test/test_chordpro/05.source
  22. 0
      test/test_chordpro/05.tex
  23. 0
      test/test_chordpro/06.sgc
  24. 0
      test/test_chordpro/06.source
  25. 0
      test/test_chordpro/06.tex
  26. 0
      test/test_chordpro/07.sgc
  27. 0
      test/test_chordpro/07.source
  28. 0
      test/test_chordpro/07.tex
  29. 0
      test/test_chordpro/08.sgc
  30. 0
      test/test_chordpro/08.source
  31. 0
      test/test_chordpro/08.tex
  32. 0
      test/test_chordpro/09.sgc
  33. 0
      test/test_chordpro/09.source
  34. 0
      test/test_chordpro/09.tex
  35. 0
      test/test_chordpro/10.sgc
  36. 0
      test/test_chordpro/10.source
  37. 0
      test/test_chordpro/10.tex
  38. 0
      test/test_chordpro/11.sgc
  39. 0
      test/test_chordpro/11.source
  40. 0
      test/test_chordpro/11.tex
  41. 0
      test/test_chordpro/12.sgc
  42. 0
      test/test_chordpro/12.source
  43. 0
      test/test_chordpro/12.tex
  44. 0
      test/test_chordpro/13.sgc
  45. 0
      test/test_chordpro/13.source
  46. 0
      test/test_chordpro/13.tex
  47. 0
      test/test_chordpro/21.sgc
  48. 0
      test/test_chordpro/21.source
  49. 0
      test/test_chordpro/21.tex
  50. 0
      test/test_chordpro/22.sgc
  51. 0
      test/test_chordpro/22.source
  52. 0
      test/test_chordpro/22.tex
  53. 0
      test/test_chordpro/23.sgc
  54. 0
      test/test_chordpro/23.source
  55. 0
      test/test_chordpro/23.tex
  56. 0
      test/test_chordpro/24.sgc
  57. 0
      test/test_chordpro/24.source
  58. 0
      test/test_chordpro/24.tex
  59. 0
      test/test_chordpro/25.sgc
  60. 0
      test/test_chordpro/25.source
  61. 0
      test/test_chordpro/25.tex
  62. 0
      test/test_chordpro/26.sgc
  63. 0
      test/test_chordpro/26.source
  64. 0
      test/test_chordpro/26.tex
  65. 0
      test/test_chordpro/27.sgc
  66. 0
      test/test_chordpro/27.source
  67. 0
      test/test_chordpro/27.tex
  68. 0
      test/test_chordpro/28.sgc
  69. 0
      test/test_chordpro/28.source
  70. 0
      test/test_chordpro/28.tex
  71. 0
      test/test_chordpro/29.sgc
  72. 0
      test/test_chordpro/29.source
  73. 0
      test/test_chordpro/29.tex
  74. 0
      test/test_chordpro/__init__.py
  75. 0
      test/test_chordpro/author_names.sgc
  76. 0
      test/test_chordpro/author_names.source
  77. 0
      test/test_chordpro/author_names.tex
  78. 0
      test/test_chordpro/chords.sgc
  79. 0
      test/test_chordpro/chords.source
  80. 0
      test/test_chordpro/chords.tex
  81. 0
      test/test_chordpro/customchords.sgc
  82. 0
      test/test_chordpro/customchords.source
  83. 0
      test/test_chordpro/customchords.tex
  84. 0
      test/test_chordpro/greensleeves.sgc
  85. 0
      test/test_chordpro/greensleeves.source
  86. 0
      test/test_chordpro/greensleeves.tex
  87. 0
      test/test_chordpro/invalid_chord.sgc
  88. 0
      test/test_chordpro/invalid_chord.source
  89. 0
      test/test_chordpro/invalid_chord.tex
  90. 0
      test/test_chordpro/invalid_customchord.sgc
  91. 0
      test/test_chordpro/invalid_customchord.source
  92. 0
      test/test_chordpro/invalid_customchord.tex
  93. 0
      test/test_chordpro/metadata.sgc
  94. 0
      test/test_chordpro/metadata.source
  95. 0
      test/test_chordpro/metadata.tex
  96. 3
      test/test_chordpro/test_parser.py
  97. 37
      test/test_doctest.py
  98. 2
      tox.ini

25
patacrep/files.py

@ -71,6 +71,21 @@ def chdir(path):
else: else:
yield 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): def load_plugins(datadirs, root_modules, keyword):
"""Load all plugins, and return a dictionary of those plugins. """Load all plugins, and return a dictionary of those plugins.
@ -101,18 +116,10 @@ def load_plugins(datadirs, root_modules, keyword):
for path for path
in sys.path in sys.path
] ]
for module_finder, name, __is_pkg in pkgutil.walk_packages( for module in iter_modules(
datadir_path + sys_path, datadir_path + sys_path,
prefix="patacrep.{}.".format(".".join(root_modules)) 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): if hasattr(module, keyword):
for (key, value) in getattr(module, keyword).items(): for (key, value) in getattr(module, keyword).items():
if key in plugins: if key in plugins:

1
patacrep/songs/chordpro/test/__init__.py

@ -1 +0,0 @@
"""Test for chordpro parser"""

4
setup.py

@ -15,7 +15,7 @@ setup(
author='The Songbook team', author='The Songbook team',
author_email='crep@team-on-fire.com', author_email='crep@team-on-fire.com',
url='https://github.com/patacrep/patacrep', url='https://github.com/patacrep/patacrep',
packages=find_packages(), packages=find_packages(exclude=["test*"]),
license="GPLv2 or any later version", license="GPLv2 or any later version",
install_requires=[ install_requires=[
"unidecode", "jinja2", "chardet", "ply", "unidecode", "jinja2", "chardet", "ply",
@ -39,6 +39,6 @@ setup(
"Topic :: Utilities", "Topic :: Utilities",
], ],
platforms=["GNU/Linux", "Windows", "MacOsX"], platforms=["GNU/Linux", "Windows", "MacOsX"],
test_suite="patacrep.test.suite", test_suite="test.suite",
long_description = open("README.rst", "r").read(), long_description = open("README.rst", "r").read(),
) )

18
patacrep/test.py → test/__init__.py

@ -16,20 +16,14 @@ def disable_logging():
logging.disable(logging.NOTSET) logging.disable(logging.NOTSET)
def suite(): def suite():
"""Return a TestSuite object, to test whole `patacrep` package. """Return a :class:`TestSuite` object, testing all module :mod:`patacrep`.
Both unittest and doctest are tested.
""" """
test_loader = unittest.defaultTestLoader test_loader = unittest.defaultTestLoader
return test_loader.discover(os.path.dirname(__file__)) return test_loader.discover(
os.path.abspath(os.path.dirname(__file__)),
def load_tests(__loader, tests, __pattern): pattern="*.py",
"""Load tests (unittests and doctests).""" top_level_dir=os.path.abspath(os.path.join(patacrep.__path__[0], "..")),
# Loading doctests )
tests.addTests(doctest.DocTestSuite(patacrep))
# Unittests are loaded by default
return tests
if __name__ == "__main__": if __name__ == "__main__":
unittest.TextTestRunner().run(suite()) unittest.TextTestRunner().run(suite())

0
patacrep/songs/chordpro/test/00.sgc → test/test_chordpro/00.sgc

0
patacrep/songs/chordpro/test/00.source → test/test_chordpro/00.source

0
patacrep/songs/chordpro/test/00.tex → test/test_chordpro/00.tex

0
patacrep/songs/chordpro/test/01.sgc → test/test_chordpro/01.sgc

0
patacrep/songs/chordpro/test/01.source → test/test_chordpro/01.source

0
patacrep/songs/chordpro/test/01.tex → test/test_chordpro/01.tex

0
patacrep/songs/chordpro/test/02.sgc → test/test_chordpro/02.sgc

0
patacrep/songs/chordpro/test/02.source → test/test_chordpro/02.source

0
patacrep/songs/chordpro/test/02.tex → test/test_chordpro/02.tex

0
patacrep/songs/chordpro/test/03.sgc → test/test_chordpro/03.sgc

0
patacrep/songs/chordpro/test/03.source → test/test_chordpro/03.source

0
patacrep/songs/chordpro/test/03.tex → test/test_chordpro/03.tex

0
patacrep/songs/chordpro/test/04.sgc → test/test_chordpro/04.sgc

0
patacrep/songs/chordpro/test/04.source → test/test_chordpro/04.source

0
patacrep/songs/chordpro/test/04.tex → test/test_chordpro/04.tex

0
patacrep/songs/chordpro/test/05.sgc → test/test_chordpro/05.sgc

0
patacrep/songs/chordpro/test/05.source → test/test_chordpro/05.source

0
patacrep/songs/chordpro/test/05.tex → test/test_chordpro/05.tex

0
patacrep/songs/chordpro/test/06.sgc → test/test_chordpro/06.sgc

0
patacrep/songs/chordpro/test/06.source → test/test_chordpro/06.source

0
patacrep/songs/chordpro/test/06.tex → test/test_chordpro/06.tex

0
patacrep/songs/chordpro/test/07.sgc → test/test_chordpro/07.sgc

0
patacrep/songs/chordpro/test/07.source → test/test_chordpro/07.source

0
patacrep/songs/chordpro/test/07.tex → test/test_chordpro/07.tex

0
patacrep/songs/chordpro/test/08.sgc → test/test_chordpro/08.sgc

0
patacrep/songs/chordpro/test/08.source → test/test_chordpro/08.source

0
patacrep/songs/chordpro/test/08.tex → test/test_chordpro/08.tex

0
patacrep/songs/chordpro/test/09.sgc → test/test_chordpro/09.sgc

0
patacrep/songs/chordpro/test/09.source → test/test_chordpro/09.source

0
patacrep/songs/chordpro/test/09.tex → test/test_chordpro/09.tex

0
patacrep/songs/chordpro/test/10.sgc → test/test_chordpro/10.sgc

0
patacrep/songs/chordpro/test/10.source → test/test_chordpro/10.source

0
patacrep/songs/chordpro/test/10.tex → test/test_chordpro/10.tex

0
patacrep/songs/chordpro/test/11.sgc → test/test_chordpro/11.sgc

0
patacrep/songs/chordpro/test/11.source → test/test_chordpro/11.source

0
patacrep/songs/chordpro/test/11.tex → test/test_chordpro/11.tex

0
patacrep/songs/chordpro/test/12.sgc → test/test_chordpro/12.sgc

0
patacrep/songs/chordpro/test/12.source → test/test_chordpro/12.source

0
patacrep/songs/chordpro/test/12.tex → test/test_chordpro/12.tex

0
patacrep/songs/chordpro/test/13.sgc → test/test_chordpro/13.sgc

0
patacrep/songs/chordpro/test/13.source → test/test_chordpro/13.source

0
patacrep/songs/chordpro/test/13.tex → test/test_chordpro/13.tex

0
patacrep/songs/chordpro/test/21.sgc → test/test_chordpro/21.sgc

0
patacrep/songs/chordpro/test/21.source → test/test_chordpro/21.source

0
patacrep/songs/chordpro/test/21.tex → test/test_chordpro/21.tex

0
patacrep/songs/chordpro/test/22.sgc → test/test_chordpro/22.sgc

0
patacrep/songs/chordpro/test/22.source → test/test_chordpro/22.source

0
patacrep/songs/chordpro/test/22.tex → test/test_chordpro/22.tex

0
patacrep/songs/chordpro/test/23.sgc → test/test_chordpro/23.sgc

0
patacrep/songs/chordpro/test/23.source → test/test_chordpro/23.source

0
patacrep/songs/chordpro/test/23.tex → test/test_chordpro/23.tex

0
patacrep/songs/chordpro/test/24.sgc → test/test_chordpro/24.sgc

0
patacrep/songs/chordpro/test/24.source → test/test_chordpro/24.source

0
patacrep/songs/chordpro/test/24.tex → test/test_chordpro/24.tex

0
patacrep/songs/chordpro/test/25.sgc → test/test_chordpro/25.sgc

0
patacrep/songs/chordpro/test/25.source → test/test_chordpro/25.source

0
patacrep/songs/chordpro/test/25.tex → test/test_chordpro/25.tex

0
patacrep/songs/chordpro/test/26.sgc → test/test_chordpro/26.sgc

0
patacrep/songs/chordpro/test/26.source → test/test_chordpro/26.source

0
patacrep/songs/chordpro/test/26.tex → test/test_chordpro/26.tex

0
patacrep/songs/chordpro/test/27.sgc → test/test_chordpro/27.sgc

0
patacrep/songs/chordpro/test/27.source → test/test_chordpro/27.source

0
patacrep/songs/chordpro/test/27.tex → test/test_chordpro/27.tex

0
patacrep/songs/chordpro/test/28.sgc → test/test_chordpro/28.sgc

0
patacrep/songs/chordpro/test/28.source → test/test_chordpro/28.source

0
patacrep/songs/chordpro/test/28.tex → test/test_chordpro/28.tex

0
patacrep/songs/chordpro/test/29.sgc → test/test_chordpro/29.sgc

0
patacrep/songs/chordpro/test/29.source → test/test_chordpro/29.source

0
patacrep/songs/chordpro/test/29.tex → test/test_chordpro/29.tex

0
test/test_chordpro/__init__.py

0
patacrep/songs/chordpro/test/author_names.sgc → test/test_chordpro/author_names.sgc

0
patacrep/songs/chordpro/test/author_names.source → test/test_chordpro/author_names.source

0
patacrep/songs/chordpro/test/author_names.tex → test/test_chordpro/author_names.tex

0
patacrep/songs/chordpro/test/chords.sgc → test/test_chordpro/chords.sgc

0
patacrep/songs/chordpro/test/chords.source → test/test_chordpro/chords.source

0
patacrep/songs/chordpro/test/chords.tex → test/test_chordpro/chords.tex

0
patacrep/songs/chordpro/test/customchords.sgc → test/test_chordpro/customchords.sgc

0
patacrep/songs/chordpro/test/customchords.source → test/test_chordpro/customchords.source

0
patacrep/songs/chordpro/test/customchords.tex → test/test_chordpro/customchords.tex

0
patacrep/songs/chordpro/test/greensleeves.sgc → test/test_chordpro/greensleeves.sgc

0
patacrep/songs/chordpro/test/greensleeves.source → test/test_chordpro/greensleeves.source

0
patacrep/songs/chordpro/test/greensleeves.tex → test/test_chordpro/greensleeves.tex

0
patacrep/songs/chordpro/test/invalid_chord.sgc → test/test_chordpro/invalid_chord.sgc

0
patacrep/songs/chordpro/test/invalid_chord.source → test/test_chordpro/invalid_chord.source

0
patacrep/songs/chordpro/test/invalid_chord.tex → test/test_chordpro/invalid_chord.tex

0
patacrep/songs/chordpro/test/invalid_customchord.sgc → test/test_chordpro/invalid_customchord.sgc

0
patacrep/songs/chordpro/test/invalid_customchord.source → test/test_chordpro/invalid_customchord.source

0
patacrep/songs/chordpro/test/invalid_customchord.tex → test/test_chordpro/invalid_customchord.tex

0
patacrep/songs/chordpro/test/metadata.sgc → test/test_chordpro/metadata.sgc

0
patacrep/songs/chordpro/test/metadata.source → test/test_chordpro/metadata.source

0
patacrep/songs/chordpro/test/metadata.tex → test/test_chordpro/metadata.tex

3
patacrep/songs/chordpro/test/test_parser.py → test/test_chordpro/test_parser.py

@ -8,7 +8,8 @@ import unittest
from patacrep.build import DEFAULT_CONFIG from patacrep.build import DEFAULT_CONFIG
from patacrep.songs.chordpro import ChordproSong from patacrep.songs.chordpro import ChordproSong
from patacrep.test import disable_logging
from .. import disable_logging
LANGUAGES = { LANGUAGES = {
'tex': 'latex', 'tex': 'latex',

37
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 <http://www.gnu.org/licenses/>.
"""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

2
tox.ini

@ -12,4 +12,4 @@ deps =
[testenv:lint] [testenv:lint]
basepython=python3.4 basepython=python3.4
deps=pylint deps=pylint
commands=pylint patacrep --rcfile=pylintrc commands=pylint patacrep test --rcfile=pylintrc

Loading…
Cancel
Save