obriencj/python-javatools

Mixed line endings in tests causing failures

Closed this issue · 1 comments

Fresh checkout (also fails under unittests, but examples below are being run with pytest) fails due to platform-specific line endings.

Failures:

FAILED tests/manifest.py::ManifestTest::test_create_sha1 - AssertionError: 'Manifest-Version: 1.0\n\nName: example.t[187 chars]\n\n' != b'Manifest-Version: 1.0\r\n\r\nName: exam[206 chars]\r\n' : Result of "...
FAILED tests/manifest.py::ManifestTest::test_create_sha512 - AssertionError: 'Manifest-Version: 1.0\n\nName: example.t[319 chars]\n\n' != b'Manifest-Version: 1.0\r\n\r\nName: exam[342 chars]\r\n' : Result of...
FAILED tests/manifest.py::ManifestTest::test_create_with_ignore - AssertionError: 'Manifest-Version: 1.0\n\nName: filename-[227 chars]\n\n' != b'Manifest-Version: 1.0\r\n\r\nName: file[244 chars]\r\n' : Resu...

Example:

E Expected:
E   b'Manifest-Version: 1.0\r\n\r\nName: filename-which-is-longer-than-80-characters-and-does-not-fit-in-\r\n java-manifest-line.txt\r\nMD5-Digest: JqsNuQ1y4orQuh4i7lEFEA==\r\nSHA-512-Digest: Y+Iuwvvuur8AXlj7+w7uYHxKpBcEWmigzGN2ewSONVkmjTXnLzZ9Oy\r\n 29Xb3fEvxDl3YroUkmCzeVoDkXE73c1w==\r\n\r\n'
E Received:
E   b'Manifest-Version: 1.0\n\nName: filename-which-is-longer-than-80-characters-and-does-not-fit-in-\n java-manifest-line.txt\nMD5-Digest: JqsNuQ1y4orQuh4i7lEFEA==\nSHA-512-Digest: Y+Iuwvvuur8AXlj7+w7uYHxKpBcEWmigzGN2ewSONVkmjTXnLzZ9Oy\n 29Xb3fEvxDl3YroUkmCzeVoDkXE73c1w==\n\n'                                                                                    

This fails due to the manifests having \r\n line endings, and reading from the subprocess we get Linux-style \n.

On Py3, the fix is simply using universal newline mode, with NamedTemporaryFile('rt') as tmp_out: (in py3, t implies the U from py2).

Note that the specification states that manifest are valid with any line endings:

   newline:                      CR LF | LF | CR (not followed by LF)

@KonstantinShemyak
#119

TkTech commented

Still an issue, but project appears to be abandoned.