Repository navigation
Conversation
Python's default text-mode writing translates "\n" to os.linesep, which on Windows turns the MD5 test fixtures into "\r\n" files. Two tests hash them in binary mode against MD5 sums computed from "\n" content: test_text_file_binary in test_checkers.py and test_assertFileMd5 in test_assertions.py. Write these fixtures with newline="" so the bytes match the hardcoded sums on every platform. Do the same for the other fixtures written next to file_with_md5, since test_assertFilesEqualMd5 compares their hashes against it. Remove the now obsolete @xfail_windows markers from the two tests, because an unexpected success makes the gunittest run fail. Based on the newline handling in OSGeo#2616 by Stefan Blumentrath, reworked against current main with AI assistance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Write the MD5 test fixtures in
test_checkers.pyandtest_assertions.pywithnewline="", so\nis not translated to\r\non Windows. These files are hashed in binary mode and compared against MD5 sums computed from\ncontent. The two other fixtures written next tofile_with_md5get the same treatment, sincetest_assertFilesEqualMd5compares their hashes against it.The
@xfail_windowsmarkers ontest_text_file_binaryandtest_assertFileMd5are removed: an unexpected success makesTestResult.wasSuccessful()return False, which would fail the gunittest run.Also fixes the
platfromtypos in thetest_text_file_platformtest name and theplatform_newlineattribute.Motivation and context
Extracted from the stale OSGeo#2616 (newline handling by @ninsbl), reworked against current
main, with AI assistance (Claude Code).How has this been tested?
Both hardcoded MD5 sums were checked against
hashlib.md5()of the\n-only content, andruff checkpasses. On a Windows CI run,TestMd5Sumsintest_checkers.pypasses, andtest_assertions.pyruns 31 tests with only the pre-existing@xfail_windowsexpected failure (test_assertLooksLike_multiline_platform_dependent).Screenshots (if appropriate)
Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.