djc / rnc2rng

RELAX NG Compact to regular syntax conversion library
MIT License
16 stars 13 forks source link

Tests fail on Windows due to leftover \r when parsing documentation #33

Closed rly closed 3 years ago

rly commented 3 years ago

Running tests on Windows 10, Python 3.8 results in 2 failures and 2 errors. The errors are due to #31.

One of the failures:

======================================================================
FAIL: TestCase('tests\\annotations.rnc')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 32, in runTest
    self.assertBestEqual(expected, actual)
  File "test.py", line 8, in assertBestEqual
    self.assertMultiLineEqual(expected, actual)
AssertionError: '<?xm[1350 chars]tion\ncontinues on the next line</a:documentat[102 chars]mar>' != '<?xm[1350 chars]tion\r\ncontinues on the next line\r</a:docume[106 chars]mar>'
  [...snip...]
    <define name="bar">
-     <a:documentation>documentation for definition
+     <a:documentation>documentation for definition
?                                                  +
- continues on the next line</a:documentation>
+ </a:documentation>ext line
  [...snip...]

Both failures are because the computed rng documentation string contains a "\r" symbol. This appears to be due to: https://github.com/djc/rnc2rng/blob/master/rnc2rng/parser.py#L543 where the "\r" symbol (a newline character in Windows) is not removed from the end of p[0].value. I'm not sure how "\r" and "\n" are removed from all the other lines, but at least here, it is left over and should be removed to ensure proper matching in the test and proper multi-line parsing.