diff --git a/test/test_chordpro/clrf.html b/test/test_chordpro/clrf.html deleted file mode 100644 index 5540af64..00000000 --- a/test/test_chordpro/clrf.html +++ /dev/null @@ -1,43 +0,0 @@ - -Lang: en
- - - -
-

This is a verse
-With a new line
-
-The second part of the verse
-Is this line -

- -

Here is a new line at the end
- -

- -

Foo bar -

- -


-And a new line
-At the beginning -

- -

New lines can also
-
-Be in chorus -

- -

New lines can also
-
-Be in bridges -

- -

New lines can also
-
-Be surrounded by spaces -

- -

New lines cannot -

-
\ No newline at end of file diff --git a/test/test_chordpro/clrf.sgc b/test/test_chordpro/clrf.sgc deleted file mode 100644 index e9bf0c62..00000000 --- a/test/test_chordpro/clrf.sgc +++ /dev/null @@ -1,41 +0,0 @@ -{lang: en} - -This is a verse -With a new line -{newline} -The second part of the verse -Is this line - - -Here is a new line at the end -{newline} - - -Foo bar - - -{newline} -And a new line -At the beginning - - -{start_of_chorus} - New lines can also - {newline} - Be in chorus -{end_of_chorus} - - -{start_of_bridge} - New lines can also - {newline} - Be in bridges -{end_of_bridge} - - -New lines can also -{newline} -Be surrounded by spaces - - -New lines cannot diff --git a/test/test_chordpro/clrf.source b/test/test_chordpro/clrf.source deleted file mode 100644 index 484df519..00000000 --- a/test/test_chordpro/clrf.source +++ /dev/null @@ -1,32 +0,0 @@ -This is a verse -With a new line -{newline} -The second part of the verse -Is this line - -Here is a new line at the end -{newline} - -Foo bar - -{newline} -And a new line -At the beginning - -{soc} -New lines can also -{newline} -Be in chorus -{eoc} - -{sob} -New lines can also -{newline} -Be in bridges -{eob} - -New lines can also - {newline} -Be surrounded by spaces - -New lines cannot {newline} appear in the middle of a line diff --git a/test/test_chordpro/clrf.tex b/test/test_chordpro/clrf.tex deleted file mode 100644 index d557de5f..00000000 --- a/test/test_chordpro/clrf.tex +++ /dev/null @@ -1,61 +0,0 @@ -\selectlanguage{english} - -\beginsong{}[ - by={ - }, -] - - -\begin{verse} - This is a verse - With a new line - ~\\ - The second part of the verse - Is this line -\end{verse} - - -\begin{verse} - Here is a new line at the end - ~\\ -\end{verse} - - -\begin{verse} - Foo bar -\end{verse} - - -\begin{verse} - ~\\ - And a new line - At the beginning -\end{verse} - - -\begin{chorus} - New lines can also - ~\\ - Be in chorus -\end{chorus} - - -\begin{bridge} - New lines can also - ~\\ - Be in bridges -\end{bridge} - - -\begin{verse} - New lines can also - ~\\ - Be surrounded by spaces -\end{verse} - - -\begin{verse} - New lines cannot -\end{verse} - -\endsong diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 3f0c652e..fd30a9b3 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -60,6 +60,12 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): "test_{}_{}".format(os.path.basename(base), dest), cls._create_test(base, dest), ) + if os.path.basename(base) == 'newline': + yield ( + "test_crlf_{}_{}".format(os.path.basename(base), dest), + cls._create_crlf_test(base, dest), + ) + @classmethod def _create_test(cls, base, dest): @@ -85,3 +91,36 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): "Test that '{base}' is correctly parsed and rendererd into '{format}' format." ).format(base=os.path.basename(base), format=dest) return test_parse_render + + @classmethod + def _create_crlf_test(cls, base, dest): + """Transform the `base` line endings into CRLF and test the compilation. + """ + + def test_parse_render(self): + """Test that `base` is correctly parsed and rendered when line endings are CRLF. + """ + if base is None or dest is None: + return + originalname = "{}.source".format(base) + chordproname = "{}.crlf.source".format(base) + with open_read(originalname) as originalfile: + with open(chordproname, 'w') as chordprofile: + for line in originalfile: + chordprofile.write(line.replace('\n', '\r\n')) + destname = "{}.{}".format(base, dest) + with open_read(destname) as expectfile: + with disable_logging(): + self.assertMultiLineEqual( + self.song_plugins[LANGUAGES[dest]]['sgc'](chordproname, self.config).render( + output=chordproname, + ).strip(), + expectfile.read().strip(), + ) + os.remove(chordproname) + + test_parse_render.__doc__ = ( + "Test that '{base}' is correctly parsed and rendererd into '{format}' format with CRLF." + ).format(base=os.path.basename(base), format=dest) + return test_parse_render +