PYTHON-5779 Coverage increase for compression_support.py#2770
Draft
aclark4life wants to merge 5 commits intomongodb:masterfrom
Draft
PYTHON-5779 Coverage increase for compression_support.py#2770aclark4life wants to merge 5 commits intomongodb:masterfrom
compression_support.py#2770aclark4life wants to merge 5 commits intomongodb:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new unit test module to increase coverage of pymongo/compression_support.py, focusing on optional-compression dependency detection, validation helpers, context selection, and zlib decompression behavior.
Changes:
- Introduces
test/test_compression_support.pywith unit tests for_have_*helpers and validation functions. - Adds coverage for
CompressionSettings.get_compression_context()anddecompress()(includingmemoryviewinput for zlib).
17f758a to
cca1bf9
Compare
Comment on lines
+51
to
+52
| self.assertIn("zlib", result) | ||
| self.assertIn("snappy", result) |
Comment on lines
+218
to
+219
| result = decompress(compressed, SnappyContext.compressor_id) | ||
| self.assertEqual(result, data) |
compression_support.py
compression_support.pycompression_support.py
compression_support.pycompression_support.py
compression_support.pycompression_support.py
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.
PYTHON-5779
Changes in this PR
Adds
test/test_compression_support.pywith unit tests forpymongo/compression_support.py:validate_compressors()— string vs. iterable input, comma-separated parsing, order preservation, empty input, unknown-name warning, and per-compressor "library unavailable" warnings (snappy / zlib / zstd, including the Py3.14 message split). Usespatch("pymongo.compression_support._have_xxx", ...)so results are deterministic regardless of which optional libraries are installed locally.validate_zlib_compression_level()— bounds (-1 / 9), out-of-rangeValueError, non-integerTypeError, and string-to-int coercion.CompressionSettings.get_compression_context()— returns the right*Contextsubclass per compressor name, picks the first compressor when several are listed, and returnsNonefor empty / unknown input.ZlibContext— compress/decompress roundtrip.decompress()— zlib branch (bytes andmemoryviewinputs), snappy and zstd roundtrips (gated on_have_snappy()/_have_zstd()), and the unknown-compressorIdValueErrorpath.zlib-dependent tests are gated on
_have_zlib()and importzliblazily so the module loads on Python builds without zlib.Test Plan
Checklist
Checklist for Author
Checklist for Reviewer