diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 330b2f3e..5777b170 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -131,13 +131,13 @@ class Chordpro2ChordproSong(ChordproSong): return filename SONG_RENDERERS = { - "latex": { - 'sgc': Chordpro2LatexSong, + "tsg": { + 'csg': Chordpro2LatexSong, }, "html": { - 'sgc': Chordpro2HtmlSong, + 'csg': Chordpro2HtmlSong, }, - "chordpro": { - 'sgc': Chordpro2ChordproSong, + "csg": { + 'csg': Chordpro2ChordproSong, }, } diff --git a/test/test_chordpro/00.sgc b/test/test_chordpro/00.csg similarity index 100% rename from test/test_chordpro/00.sgc rename to test/test_chordpro/00.csg diff --git a/test/test_chordpro/00.source b/test/test_chordpro/00.csg.source similarity index 100% rename from test/test_chordpro/00.source rename to test/test_chordpro/00.csg.source diff --git a/test/test_chordpro/00.tex b/test/test_chordpro/00.tsg similarity index 100% rename from test/test_chordpro/00.tex rename to test/test_chordpro/00.tsg diff --git a/test/test_chordpro/01.sgc b/test/test_chordpro/01.csg similarity index 100% rename from test/test_chordpro/01.sgc rename to test/test_chordpro/01.csg diff --git a/test/test_chordpro/01.source b/test/test_chordpro/01.csg.source similarity index 100% rename from test/test_chordpro/01.source rename to test/test_chordpro/01.csg.source diff --git a/test/test_chordpro/01.tex b/test/test_chordpro/01.tsg similarity index 100% rename from test/test_chordpro/01.tex rename to test/test_chordpro/01.tsg diff --git a/test/test_chordpro/02.sgc b/test/test_chordpro/02.csg similarity index 100% rename from test/test_chordpro/02.sgc rename to test/test_chordpro/02.csg diff --git a/test/test_chordpro/02.source b/test/test_chordpro/02.csg.source similarity index 100% rename from test/test_chordpro/02.source rename to test/test_chordpro/02.csg.source diff --git a/test/test_chordpro/02.tex b/test/test_chordpro/02.tsg similarity index 100% rename from test/test_chordpro/02.tex rename to test/test_chordpro/02.tsg diff --git a/test/test_chordpro/03.sgc b/test/test_chordpro/03.csg similarity index 100% rename from test/test_chordpro/03.sgc rename to test/test_chordpro/03.csg diff --git a/test/test_chordpro/03.source b/test/test_chordpro/03.csg.source similarity index 100% rename from test/test_chordpro/03.source rename to test/test_chordpro/03.csg.source diff --git a/test/test_chordpro/03.tex b/test/test_chordpro/03.tsg similarity index 100% rename from test/test_chordpro/03.tex rename to test/test_chordpro/03.tsg diff --git a/test/test_chordpro/04.sgc b/test/test_chordpro/04.csg similarity index 100% rename from test/test_chordpro/04.sgc rename to test/test_chordpro/04.csg diff --git a/test/test_chordpro/04.source b/test/test_chordpro/04.csg.source similarity index 100% rename from test/test_chordpro/04.source rename to test/test_chordpro/04.csg.source diff --git a/test/test_chordpro/04.tex b/test/test_chordpro/04.tsg similarity index 100% rename from test/test_chordpro/04.tex rename to test/test_chordpro/04.tsg diff --git a/test/test_chordpro/05.sgc b/test/test_chordpro/05.csg similarity index 100% rename from test/test_chordpro/05.sgc rename to test/test_chordpro/05.csg diff --git a/test/test_chordpro/05.source b/test/test_chordpro/05.csg.source similarity index 100% rename from test/test_chordpro/05.source rename to test/test_chordpro/05.csg.source diff --git a/test/test_chordpro/05.tex b/test/test_chordpro/05.tsg similarity index 100% rename from test/test_chordpro/05.tex rename to test/test_chordpro/05.tsg diff --git a/test/test_chordpro/06.sgc b/test/test_chordpro/06.csg similarity index 100% rename from test/test_chordpro/06.sgc rename to test/test_chordpro/06.csg diff --git a/test/test_chordpro/06.source b/test/test_chordpro/06.csg.source similarity index 100% rename from test/test_chordpro/06.source rename to test/test_chordpro/06.csg.source diff --git a/test/test_chordpro/06.tex b/test/test_chordpro/06.tsg similarity index 100% rename from test/test_chordpro/06.tex rename to test/test_chordpro/06.tsg diff --git a/test/test_chordpro/07.sgc b/test/test_chordpro/07.csg similarity index 100% rename from test/test_chordpro/07.sgc rename to test/test_chordpro/07.csg diff --git a/test/test_chordpro/07.source b/test/test_chordpro/07.csg.source similarity index 100% rename from test/test_chordpro/07.source rename to test/test_chordpro/07.csg.source diff --git a/test/test_chordpro/07.tex b/test/test_chordpro/07.tsg similarity index 100% rename from test/test_chordpro/07.tex rename to test/test_chordpro/07.tsg diff --git a/test/test_chordpro/08.sgc b/test/test_chordpro/08.csg similarity index 100% rename from test/test_chordpro/08.sgc rename to test/test_chordpro/08.csg diff --git a/test/test_chordpro/08.source b/test/test_chordpro/08.csg.source similarity index 100% rename from test/test_chordpro/08.source rename to test/test_chordpro/08.csg.source diff --git a/test/test_chordpro/08.tex b/test/test_chordpro/08.tsg similarity index 100% rename from test/test_chordpro/08.tex rename to test/test_chordpro/08.tsg diff --git a/test/test_chordpro/09.sgc b/test/test_chordpro/09.csg similarity index 100% rename from test/test_chordpro/09.sgc rename to test/test_chordpro/09.csg diff --git a/test/test_chordpro/09.source b/test/test_chordpro/09.csg.source similarity index 100% rename from test/test_chordpro/09.source rename to test/test_chordpro/09.csg.source diff --git a/test/test_chordpro/09.tex b/test/test_chordpro/09.tsg similarity index 100% rename from test/test_chordpro/09.tex rename to test/test_chordpro/09.tsg diff --git a/test/test_chordpro/10.sgc b/test/test_chordpro/10.csg similarity index 100% rename from test/test_chordpro/10.sgc rename to test/test_chordpro/10.csg diff --git a/test/test_chordpro/10.source b/test/test_chordpro/10.csg.source similarity index 100% rename from test/test_chordpro/10.source rename to test/test_chordpro/10.csg.source diff --git a/test/test_chordpro/10.tex b/test/test_chordpro/10.tsg similarity index 100% rename from test/test_chordpro/10.tex rename to test/test_chordpro/10.tsg diff --git a/test/test_chordpro/11.sgc b/test/test_chordpro/11.csg similarity index 100% rename from test/test_chordpro/11.sgc rename to test/test_chordpro/11.csg diff --git a/test/test_chordpro/11.source b/test/test_chordpro/11.csg.source similarity index 100% rename from test/test_chordpro/11.source rename to test/test_chordpro/11.csg.source diff --git a/test/test_chordpro/11.tex b/test/test_chordpro/11.tsg similarity index 100% rename from test/test_chordpro/11.tex rename to test/test_chordpro/11.tsg diff --git a/test/test_chordpro/12.sgc b/test/test_chordpro/12.csg similarity index 100% rename from test/test_chordpro/12.sgc rename to test/test_chordpro/12.csg diff --git a/test/test_chordpro/12.source b/test/test_chordpro/12.csg.source similarity index 100% rename from test/test_chordpro/12.source rename to test/test_chordpro/12.csg.source diff --git a/test/test_chordpro/12.tex b/test/test_chordpro/12.tsg similarity index 100% rename from test/test_chordpro/12.tex rename to test/test_chordpro/12.tsg diff --git a/test/test_chordpro/13.sgc b/test/test_chordpro/13.csg similarity index 100% rename from test/test_chordpro/13.sgc rename to test/test_chordpro/13.csg diff --git a/test/test_chordpro/13.source b/test/test_chordpro/13.csg.source similarity index 100% rename from test/test_chordpro/13.source rename to test/test_chordpro/13.csg.source diff --git a/test/test_chordpro/13.tex b/test/test_chordpro/13.tsg similarity index 100% rename from test/test_chordpro/13.tex rename to test/test_chordpro/13.tsg diff --git a/test/test_chordpro/21.sgc b/test/test_chordpro/21.csg similarity index 100% rename from test/test_chordpro/21.sgc rename to test/test_chordpro/21.csg diff --git a/test/test_chordpro/21.source b/test/test_chordpro/21.csg.source similarity index 100% rename from test/test_chordpro/21.source rename to test/test_chordpro/21.csg.source diff --git a/test/test_chordpro/21.tex b/test/test_chordpro/21.tsg similarity index 100% rename from test/test_chordpro/21.tex rename to test/test_chordpro/21.tsg diff --git a/test/test_chordpro/22.sgc b/test/test_chordpro/22.csg similarity index 100% rename from test/test_chordpro/22.sgc rename to test/test_chordpro/22.csg diff --git a/test/test_chordpro/22.source b/test/test_chordpro/22.csg.source similarity index 100% rename from test/test_chordpro/22.source rename to test/test_chordpro/22.csg.source diff --git a/test/test_chordpro/22.tex b/test/test_chordpro/22.tsg similarity index 100% rename from test/test_chordpro/22.tex rename to test/test_chordpro/22.tsg diff --git a/test/test_chordpro/23.sgc b/test/test_chordpro/23.csg similarity index 100% rename from test/test_chordpro/23.sgc rename to test/test_chordpro/23.csg diff --git a/test/test_chordpro/23.source b/test/test_chordpro/23.csg.source similarity index 100% rename from test/test_chordpro/23.source rename to test/test_chordpro/23.csg.source diff --git a/test/test_chordpro/23.tex b/test/test_chordpro/23.tsg similarity index 100% rename from test/test_chordpro/23.tex rename to test/test_chordpro/23.tsg diff --git a/test/test_chordpro/24.sgc b/test/test_chordpro/24.csg similarity index 100% rename from test/test_chordpro/24.sgc rename to test/test_chordpro/24.csg diff --git a/test/test_chordpro/24.source b/test/test_chordpro/24.csg.source similarity index 100% rename from test/test_chordpro/24.source rename to test/test_chordpro/24.csg.source diff --git a/test/test_chordpro/24.tex b/test/test_chordpro/24.tsg similarity index 100% rename from test/test_chordpro/24.tex rename to test/test_chordpro/24.tsg diff --git a/test/test_chordpro/25.sgc b/test/test_chordpro/25.csg similarity index 100% rename from test/test_chordpro/25.sgc rename to test/test_chordpro/25.csg diff --git a/test/test_chordpro/25.source b/test/test_chordpro/25.csg.source similarity index 100% rename from test/test_chordpro/25.source rename to test/test_chordpro/25.csg.source diff --git a/test/test_chordpro/25.tex b/test/test_chordpro/25.tsg similarity index 100% rename from test/test_chordpro/25.tex rename to test/test_chordpro/25.tsg diff --git a/test/test_chordpro/26.sgc b/test/test_chordpro/26.csg similarity index 100% rename from test/test_chordpro/26.sgc rename to test/test_chordpro/26.csg diff --git a/test/test_chordpro/26.source b/test/test_chordpro/26.csg.source similarity index 100% rename from test/test_chordpro/26.source rename to test/test_chordpro/26.csg.source diff --git a/test/test_chordpro/26.tex b/test/test_chordpro/26.tsg similarity index 100% rename from test/test_chordpro/26.tex rename to test/test_chordpro/26.tsg diff --git a/test/test_chordpro/27.sgc b/test/test_chordpro/27.csg similarity index 100% rename from test/test_chordpro/27.sgc rename to test/test_chordpro/27.csg diff --git a/test/test_chordpro/27.source b/test/test_chordpro/27.csg.source similarity index 100% rename from test/test_chordpro/27.source rename to test/test_chordpro/27.csg.source diff --git a/test/test_chordpro/27.tex b/test/test_chordpro/27.tsg similarity index 100% rename from test/test_chordpro/27.tex rename to test/test_chordpro/27.tsg diff --git a/test/test_chordpro/28.sgc b/test/test_chordpro/28.csg similarity index 100% rename from test/test_chordpro/28.sgc rename to test/test_chordpro/28.csg diff --git a/test/test_chordpro/28.source b/test/test_chordpro/28.csg.source similarity index 100% rename from test/test_chordpro/28.source rename to test/test_chordpro/28.csg.source diff --git a/test/test_chordpro/28.tex b/test/test_chordpro/28.tsg similarity index 100% rename from test/test_chordpro/28.tex rename to test/test_chordpro/28.tsg diff --git a/test/test_chordpro/29.sgc b/test/test_chordpro/29.csg similarity index 100% rename from test/test_chordpro/29.sgc rename to test/test_chordpro/29.csg diff --git a/test/test_chordpro/29.source b/test/test_chordpro/29.csg.source similarity index 100% rename from test/test_chordpro/29.source rename to test/test_chordpro/29.csg.source diff --git a/test/test_chordpro/29.tex b/test/test_chordpro/29.tsg similarity index 100% rename from test/test_chordpro/29.tex rename to test/test_chordpro/29.tsg diff --git a/test/test_chordpro/author_names.sgc b/test/test_chordpro/author_names.csg similarity index 100% rename from test/test_chordpro/author_names.sgc rename to test/test_chordpro/author_names.csg diff --git a/test/test_chordpro/author_names.source b/test/test_chordpro/author_names.csg.source similarity index 100% rename from test/test_chordpro/author_names.source rename to test/test_chordpro/author_names.csg.source diff --git a/test/test_chordpro/author_names.tex b/test/test_chordpro/author_names.tsg similarity index 100% rename from test/test_chordpro/author_names.tex rename to test/test_chordpro/author_names.tsg diff --git a/test/test_chordpro/chords.sgc b/test/test_chordpro/chords.csg similarity index 100% rename from test/test_chordpro/chords.sgc rename to test/test_chordpro/chords.csg diff --git a/test/test_chordpro/chords.source b/test/test_chordpro/chords.csg.source similarity index 100% rename from test/test_chordpro/chords.source rename to test/test_chordpro/chords.csg.source diff --git a/test/test_chordpro/chords.tex b/test/test_chordpro/chords.tsg similarity index 100% rename from test/test_chordpro/chords.tex rename to test/test_chordpro/chords.tsg diff --git a/test/test_chordpro/customchords.sgc b/test/test_chordpro/customchords.csg similarity index 100% rename from test/test_chordpro/customchords.sgc rename to test/test_chordpro/customchords.csg diff --git a/test/test_chordpro/customchords.source b/test/test_chordpro/customchords.csg.source similarity index 100% rename from test/test_chordpro/customchords.source rename to test/test_chordpro/customchords.csg.source diff --git a/test/test_chordpro/customchords.tex b/test/test_chordpro/customchords.tsg similarity index 100% rename from test/test_chordpro/customchords.tex rename to test/test_chordpro/customchords.tsg diff --git a/test/test_chordpro/errors/invalid_content.source b/test/test_chordpro/errors/invalid_content.csg.source similarity index 100% rename from test/test_chordpro/errors/invalid_content.source rename to test/test_chordpro/errors/invalid_content.csg.source diff --git a/test/test_chordpro/greensleeves.sgc b/test/test_chordpro/greensleeves.csg similarity index 100% rename from test/test_chordpro/greensleeves.sgc rename to test/test_chordpro/greensleeves.csg diff --git a/test/test_chordpro/greensleeves.source b/test/test_chordpro/greensleeves.csg.source similarity index 100% rename from test/test_chordpro/greensleeves.source rename to test/test_chordpro/greensleeves.csg.source diff --git a/test/test_chordpro/greensleeves.tex b/test/test_chordpro/greensleeves.tsg similarity index 100% rename from test/test_chordpro/greensleeves.tex rename to test/test_chordpro/greensleeves.tsg diff --git a/test/test_chordpro/invalid_chord.sgc b/test/test_chordpro/invalid_chord.csg similarity index 100% rename from test/test_chordpro/invalid_chord.sgc rename to test/test_chordpro/invalid_chord.csg diff --git a/test/test_chordpro/invalid_chord.source b/test/test_chordpro/invalid_chord.csg.source similarity index 100% rename from test/test_chordpro/invalid_chord.source rename to test/test_chordpro/invalid_chord.csg.source diff --git a/test/test_chordpro/invalid_chord.tex b/test/test_chordpro/invalid_chord.tsg similarity index 100% rename from test/test_chordpro/invalid_chord.tex rename to test/test_chordpro/invalid_chord.tsg diff --git a/test/test_chordpro/invalid_customchord.sgc b/test/test_chordpro/invalid_customchord.csg similarity index 100% rename from test/test_chordpro/invalid_customchord.sgc rename to test/test_chordpro/invalid_customchord.csg diff --git a/test/test_chordpro/invalid_customchord.source b/test/test_chordpro/invalid_customchord.csg.source similarity index 100% rename from test/test_chordpro/invalid_customchord.source rename to test/test_chordpro/invalid_customchord.csg.source diff --git a/test/test_chordpro/invalid_customchord.tex b/test/test_chordpro/invalid_customchord.tsg similarity index 100% rename from test/test_chordpro/invalid_customchord.tex rename to test/test_chordpro/invalid_customchord.tsg diff --git a/test/test_chordpro/invalid_directive.sgc b/test/test_chordpro/invalid_directive.csg similarity index 100% rename from test/test_chordpro/invalid_directive.sgc rename to test/test_chordpro/invalid_directive.csg diff --git a/test/test_chordpro/invalid_directive.source b/test/test_chordpro/invalid_directive.csg.source similarity index 100% rename from test/test_chordpro/invalid_directive.source rename to test/test_chordpro/invalid_directive.csg.source diff --git a/test/test_chordpro/invalid_directive.tex b/test/test_chordpro/invalid_directive.tsg similarity index 100% rename from test/test_chordpro/invalid_directive.tex rename to test/test_chordpro/invalid_directive.tsg diff --git a/test/test_chordpro/lang.sgc b/test/test_chordpro/lang.csg similarity index 100% rename from test/test_chordpro/lang.sgc rename to test/test_chordpro/lang.csg diff --git a/test/test_chordpro/lang.source b/test/test_chordpro/lang.csg.source similarity index 100% rename from test/test_chordpro/lang.source rename to test/test_chordpro/lang.csg.source diff --git a/test/test_chordpro/metadata.sgc b/test/test_chordpro/metadata.csg similarity index 100% rename from test/test_chordpro/metadata.sgc rename to test/test_chordpro/metadata.csg diff --git a/test/test_chordpro/metadata.source b/test/test_chordpro/metadata.csg.source similarity index 100% rename from test/test_chordpro/metadata.source rename to test/test_chordpro/metadata.csg.source diff --git a/test/test_chordpro/metadata.tex b/test/test_chordpro/metadata.tsg similarity index 100% rename from test/test_chordpro/metadata.tex rename to test/test_chordpro/metadata.tsg diff --git a/test/test_chordpro/newline.crlf.sgc b/test/test_chordpro/newline.crlf.csg similarity index 100% rename from test/test_chordpro/newline.crlf.sgc rename to test/test_chordpro/newline.crlf.csg diff --git a/test/test_chordpro/newline.crlf.csg.source b/test/test_chordpro/newline.crlf.csg.source new file mode 100644 index 00000000..2071e66d --- /dev/null +++ b/test/test_chordpro/newline.crlf.csg.source @@ -0,0 +1,2 @@ +# This content will be overwritten with `newline.csg.source` content +# with windows line endings (CRLF) - for testing purposes diff --git a/test/test_chordpro/newline.crlf.source b/test/test_chordpro/newline.crlf.source deleted file mode 100644 index bd45d5ce..00000000 --- a/test/test_chordpro/newline.crlf.source +++ /dev/null @@ -1,2 +0,0 @@ -# This content will be overwritten with `newline.source` content -# with windows line endings (CRLF) - for testing purposes diff --git a/test/test_chordpro/newline.crlf.tex b/test/test_chordpro/newline.crlf.tsg similarity index 100% rename from test/test_chordpro/newline.crlf.tex rename to test/test_chordpro/newline.crlf.tsg diff --git a/test/test_chordpro/newline.sgc b/test/test_chordpro/newline.csg similarity index 100% rename from test/test_chordpro/newline.sgc rename to test/test_chordpro/newline.csg diff --git a/test/test_chordpro/newline.source b/test/test_chordpro/newline.csg.source similarity index 100% rename from test/test_chordpro/newline.source rename to test/test_chordpro/newline.csg.source diff --git a/test/test_chordpro/newline.tex b/test/test_chordpro/newline.tsg similarity index 100% rename from test/test_chordpro/newline.tex rename to test/test_chordpro/newline.tsg diff --git a/test/test_chordpro/nolyrics.sgc b/test/test_chordpro/nolyrics.csg similarity index 100% rename from test/test_chordpro/nolyrics.sgc rename to test/test_chordpro/nolyrics.csg diff --git a/test/test_chordpro/nolyrics.source b/test/test_chordpro/nolyrics.csg.source similarity index 100% rename from test/test_chordpro/nolyrics.source rename to test/test_chordpro/nolyrics.csg.source diff --git a/test/test_chordpro/nolyrics.tex b/test/test_chordpro/nolyrics.tsg similarity index 100% rename from test/test_chordpro/nolyrics.tex rename to test/test_chordpro/nolyrics.tsg diff --git a/test/test_chordpro/tags.sgc b/test/test_chordpro/tags.csg similarity index 100% rename from test/test_chordpro/tags.sgc rename to test/test_chordpro/tags.csg diff --git a/test/test_chordpro/tags.source b/test/test_chordpro/tags.csg.source similarity index 100% rename from test/test_chordpro/tags.source rename to test/test_chordpro/tags.csg.source diff --git a/test/test_chordpro/tags.tex b/test/test_chordpro/tags.tsg similarity index 100% rename from test/test_chordpro/tags.tex rename to test/test_chordpro/tags.tsg diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 5d8a64da..9ebe3e00 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -15,17 +15,13 @@ from patacrep.encoding import open_read from .. import disable_logging from .. import dynamic # pylint: disable=unused-import -LANGUAGES = { - 'tex': 'latex', - 'sgc': 'chordpro', - 'html': 'html', -} +OUTPUTS = ['csg', 'tsg', 'html'] class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Test of chorpro parser, and several renderers. For any given `foo.source`, it is parsed as a chordpro file, and should be - rendered as `foo.sgc` with the chordpro renderer, and `foo.tex` with the + rendered as `foo.csg` with the chordpro renderer, and `foo.tsg` with the latex renderer. This class does nothing by itself, but its metaclass populates it with test @@ -50,15 +46,15 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): with files.chdir(resource_filename(__name__, ""), *path): yield - def assertRender(self, base, destformat): # pylint: disable=invalid-name - """Assert that `{base}.source` is correctly rendered in the `destformat`. + def assertRender(self, base, in_format, out_format): # pylint: disable=invalid-name + """Assert that `{base}.source` is correctly rendered in the `out_format`. """ - sourcename = "{}.source".format(base) - destname = "{}.{}".format(base, destformat) + sourcename = "{}.{}.source".format(base, in_format) + destname = "{}.{}".format(base, out_format) with self.chdir(): with open_read(destname) as expectfile: with disable_logging(): - song = self.song_plugins[LANGUAGES[destformat]]['sgc'](sourcename, self.config) + song = self.song_plugins[out_format][in_format](sourcename, self.config) self.assertMultiLineEqual( song.render().strip(), expectfile.read().strip(), @@ -79,45 +75,47 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): keyword='SONG_RENDERERS', ) with cls.chdir(): - for source in sorted(glob.glob('*.source')): - base = source[:-len(".source")] - for dest in LANGUAGES: - destname = "{}.{}".format(base, dest) - if not os.path.exists(destname): + for source in sorted(glob.glob('*.*.source')): + [*base, in_format, _] = source.split('.') + base = '.'.join(base) + for out_format in OUTPUTS: + outname = "{}.{}".format(base, out_format) + if not os.path.exists(outname): continue yield ( - "test_{}_{}".format(base, dest), - cls._create_test(base, dest), + "test_{}_{}_2_{}".format(base, in_format, out_format), + cls._create_test(base, in_format, out_format), ) with cls.chdir('errors'): - for source in sorted(glob.glob('*.source')): - base = source[:-len(".source")] + for source in sorted(glob.glob('*.*.source')): + [*base, in_format, _] = source.split('.') + base = '.'.join(base) yield ( - "test_{}_failure".format(base), - cls._create_failure(base), + "test_{}_{}_failure".format(base, in_format), + cls._create_failure(base, in_format), ) @classmethod - def _create_test(cls, base, dest): - """Return a function testing that `base` compilation in `dest` format. + def _create_test(cls, base, in_format, out_format): + """Return a function testing that `base` compilation in `out_format` format. """ - test_parse_render = lambda self: self.assertRender(base, dest) + test_parse_render = lambda self: self.assertRender(base, in_format, out_format) test_parse_render.__doc__ = ( - "Test that '{base}' is correctly parsed and rendererd into '{format}' format." - ).format(base=os.path.basename(base), format=dest) + "Test that '{base}.{in_format}' is correctly parsed and rendererd into '{out_format}'." + ).format(base=os.path.basename(base), in_format=in_format, out_format=out_format) return test_parse_render @classmethod - def _create_failure(cls, base): + def _create_failure(cls, base, in_format, out_format='tsg'): """Return a function testing that `base` parsing fails. """ def test_parse_failure(self): """Test that `base` parsing fails.""" - sourcename = "{}.source".format(base) + sourcename = "{}.{}.source".format(base, in_format) with self.chdir('errors'): - parser = self.song_plugins[LANGUAGES['sgc']]['sgc'] + parser = self.song_plugins[out_format][in_format] self.assertRaises(SyntaxError, parser, sourcename, self.config) test_parse_failure.__doc__ = ( @@ -130,9 +128,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Overwrite `*.crlf.source` files to force the CRLF line endings. """ with cls.chdir(): - for crlfname in sorted(glob.glob('*.crlf.source')): - base = crlfname[:-len(".crlf.source")] - sourcename = base + ".source" + for crlfname in sorted(glob.glob('*.crlf.*.source')): + [*base, _, in_format, source] = crlfname.split('.') + sourcename = '.'.join(base + [in_format, source]) with open_read(sourcename) as sourcefile: with open(crlfname, 'w') as crlffile: for line in sourcefile: @@ -146,7 +144,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): # with windows line endings (CRLF) - for testing purposes """ with cls.chdir(): - for crlfname in sorted(glob.glob('*.crlf.source')): - base = crlfname[:-len(".crlf.source")] + for crlfname in sorted(glob.glob('*.crlf.*.source')): + [*base, crlf, in_format, _] = crlfname.split('.') + base = '.'.join(base + [in_format]) with open(crlfname, 'w') as crlffile: crlffile.write(crlf_msg.format(base)) diff --git a/test/test_chordpro/ukulelechords.sgc b/test/test_chordpro/ukulelechords.csg similarity index 100% rename from test/test_chordpro/ukulelechords.sgc rename to test/test_chordpro/ukulelechords.csg diff --git a/test/test_chordpro/ukulelechords.source b/test/test_chordpro/ukulelechords.csg.source similarity index 100% rename from test/test_chordpro/ukulelechords.source rename to test/test_chordpro/ukulelechords.csg.source diff --git a/test/test_chordpro/ukulelechords.tex b/test/test_chordpro/ukulelechords.tsg similarity index 100% rename from test/test_chordpro/ukulelechords.tex rename to test/test_chordpro/ukulelechords.tsg