Browse Source

[chorpro][test] Simplifying parsing and compilation tests: preparation for LaTeX tests

pull/79/head
Louis 9 years ago
parent
commit
96697be9d1
  1. 3
      patacrep/songs/chordpro/data/chordpro/song
  2. 0
      patacrep/songs/chordpro/test/00.sgc.sgc
  3. 0
      patacrep/songs/chordpro/test/00.sgc.source
  4. 0
      patacrep/songs/chordpro/test/01.sgc.sgc
  5. 0
      patacrep/songs/chordpro/test/01.sgc.source
  6. 0
      patacrep/songs/chordpro/test/02.sgc.sgc
  7. 0
      patacrep/songs/chordpro/test/02.sgc.source
  8. 0
      patacrep/songs/chordpro/test/03.sgc.sgc
  9. 0
      patacrep/songs/chordpro/test/03.sgc.source
  10. 0
      patacrep/songs/chordpro/test/04.sgc.sgc
  11. 0
      patacrep/songs/chordpro/test/04.sgc.source
  12. 0
      patacrep/songs/chordpro/test/05.sgc.sgc
  13. 0
      patacrep/songs/chordpro/test/05.sgc.source
  14. 0
      patacrep/songs/chordpro/test/06.sgc.sgc
  15. 0
      patacrep/songs/chordpro/test/06.sgc.source
  16. 0
      patacrep/songs/chordpro/test/07.sgc.sgc
  17. 0
      patacrep/songs/chordpro/test/07.sgc.source
  18. 0
      patacrep/songs/chordpro/test/08.sgc.sgc
  19. 0
      patacrep/songs/chordpro/test/08.sgc.source
  20. 0
      patacrep/songs/chordpro/test/09.sgc.sgc
  21. 0
      patacrep/songs/chordpro/test/09.sgc.source
  22. 0
      patacrep/songs/chordpro/test/10.sgc.sgc
  23. 0
      patacrep/songs/chordpro/test/10.sgc.source
  24. 0
      patacrep/songs/chordpro/test/11.sgc.sgc
  25. 0
      patacrep/songs/chordpro/test/11.sgc.source
  26. 0
      patacrep/songs/chordpro/test/12.sgc.sgc
  27. 0
      patacrep/songs/chordpro/test/12.sgc.source
  28. 0
      patacrep/songs/chordpro/test/13.sgc.sgc
  29. 0
      patacrep/songs/chordpro/test/13.sgc.source
  30. 0
      patacrep/songs/chordpro/test/21.sgc.sgc
  31. 0
      patacrep/songs/chordpro/test/21.sgc.source
  32. 0
      patacrep/songs/chordpro/test/22.sgc.sgc
  33. 0
      patacrep/songs/chordpro/test/22.sgc.source
  34. 0
      patacrep/songs/chordpro/test/23.sgc.sgc
  35. 0
      patacrep/songs/chordpro/test/23.sgc.source
  36. 0
      patacrep/songs/chordpro/test/24.sgc.sgc
  37. 0
      patacrep/songs/chordpro/test/24.sgc.source
  38. 0
      patacrep/songs/chordpro/test/25.sgc.sgc
  39. 0
      patacrep/songs/chordpro/test/25.sgc.source
  40. 0
      patacrep/songs/chordpro/test/26.sgc.sgc
  41. 0
      patacrep/songs/chordpro/test/26.sgc.source
  42. 0
      patacrep/songs/chordpro/test/27.sgc.sgc
  43. 0
      patacrep/songs/chordpro/test/27.sgc.source
  44. 0
      patacrep/songs/chordpro/test/28.sgc.sgc
  45. 0
      patacrep/songs/chordpro/test/28.sgc.source
  46. 0
      patacrep/songs/chordpro/test/29.sgc.sgc
  47. 0
      patacrep/songs/chordpro/test/29.sgc.source
  48. 1
      patacrep/songs/chordpro/test/30.sgc
  49. 0
      patacrep/songs/chordpro/test/chords.sgc.sgc
  50. 0
      patacrep/songs/chordpro/test/chords.sgc.source
  51. 0
      patacrep/songs/chordpro/test/customchords.sgc.sgc
  52. 0
      patacrep/songs/chordpro/test/customchords.sgc.source
  53. 0
      patacrep/songs/chordpro/test/greensleeves.sgc.sgc
  54. 0
      patacrep/songs/chordpro/test/greensleeves.sgc.source
  55. 0
      patacrep/songs/chordpro/test/invalid_chord.sgc.sgc
  56. 0
      patacrep/songs/chordpro/test/invalid_chord.sgc.source
  57. 0
      patacrep/songs/chordpro/test/invalid_customchord.sgc.sgc
  58. 0
      patacrep/songs/chordpro/test/invalid_customchord.sgc.source
  59. 0
      patacrep/songs/chordpro/test/metadata.sgc.sgc
  60. 0
      patacrep/songs/chordpro/test/metadata.sgc.source
  61. 60
      patacrep/songs/chordpro/test/test_parser.py

3
patacrep/songs/chordpro/data/chordpro/song

@ -11,7 +11,8 @@
(*- for title in titles -*)
{title: (( title ))}
(* endfor -*)
(* for author in authors -*)
(*- for author in authors -*)
{artist: (( author[1] )) (( author[0] ))}
(* endfor *)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1
patacrep/songs/chordpro/test/30.sgc

@ -1 +0,0 @@
[A]A line starting with a chord

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

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

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

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

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

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

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

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

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

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

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

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

60
patacrep/songs/chordpro/test/test_parser.py

@ -11,49 +11,33 @@ from patacrep.songs.chordpro import ChordproSong
from patacrep.test import disable_logging
class ParserTxtRenderer(unittest.TestCase):
"""Test parser, and renderer as a txt file."""
class TestParsingRendering(unittest.TestCase):
"""Test parsing and rendering"""
maxDiff = None
def __init__(self, methodname="runTest", basename=None):
super().__init__(methodname)
self.basename = basename
def shortDescription(self):
return "Parsing file '{}.txt'.".format(self.basename)
def runTest(self):
"""Test txt output (default, debug output)."""
# pylint: disable=invalid-name
if self.basename is None:
return
def test_all(self):
config = DEFAULT_CONFIG.copy()
config.update({
'encoding': 'utf8',
'_compiled_authwords': {},
})
with open("{}.txt".format(self.basename), 'r', encoding='utf8') as expectfile:
chordproname = "{}.sgc".format(self.basename)
with disable_logging():
self.assertMultiLineEqual(
ChordproSong(None, chordproname, config).render(
output=chordproname,
output_format="chordpro",
).strip(),
expectfile.read().replace(
"DIRNAME",
os.path.dirname(self.basename),
).strip(),
)
def load_tests(__loader, tests, __pattern):
"""Load several tests given test files present in the directory."""
# Load all txt files as tests
for txt in sorted(glob.glob(os.path.join(
os.path.dirname(__file__),
'*.txt',
))):
tests.addTest(ParserTxtRenderer(basename=txt[:-len('.txt')]))
return tests
for source in sorted(glob.glob(os.path.join(
os.path.dirname(__file__),
'*.source',
))):
base = source[:-len(".source")]
with open("{}.sgc".format(base), 'r', encoding='utf8') as expectfile:
chordproname = "{}.source".format(base)
with disable_logging():
with self.subTest(base=os.path.basename(base)):
self.assertMultiLineEqual(
ChordproSong(None, chordproname, config).render(
output=chordproname,
output_format="chordpro",
).strip(),
expectfile.read().replace(
"DIRNAME",
os.path.dirname(base),
).strip(),
)

Loading…
Cancel
Save