PYTHON-5774 Increase daemon.py coverage to 63%#2759
Open
aclark4life wants to merge 2 commits intomongodb:masterfrom
Open
PYTHON-5774 Increase daemon.py coverage to 63%#2759aclark4life wants to merge 2 commits intomongodb:masterfrom
aclark4life wants to merge 2 commits intomongodb:masterfrom
Conversation
Add test/test_daemon.py covering previously untested branches: - _popen_wait: success, TimeoutExpired, and None timeout - _silence_resource_warning: sets returncode to 0, no-op for None - _spawn (Unix): success and FileNotFoundError warning - _spawn_daemon_double_popen: intermediate args, wait timeout, timeout swallowing - _spawn_daemon (Unix): double-Popen path and sys.executable fallback - _spawn_daemon (Windows): success and FileNotFoundError warning (skipped on Unix) - __main__ block: runs as script and exits with code 0
Expand TestSpawnDaemonWindows with three new tests: - test_uses_detached_process_flag: verifies DETACHED_PROCESS is passed as creationflags to Popen so the child survives parent exit - test_uses_devnull_for_stdio: verifies stdin/stdout/stderr are all redirected to devnull to fully detach from the parent console - test_detached_process_constant_value: verifies _DETACHED_PROCESS equals 0x00000008 per the Windows process creation flag API
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a dedicated unit-test module to increase coverage of pymongo.daemon, focusing on the cross-platform daemon spawning helpers used by client-side encryption.
Changes:
- Introduces
test/test_daemon.pywith unit tests for_popen_wait,_silence_resource_warning, and daemon spawning paths on Unix and Windows. - Adds coverage for timeout handling,
FileNotFoundErrorwarning behavior, and the Unixsys.executablefallback logic. - Adds a Unix-only subprocess test that runs
pymongo.daemonas a module to exercise the__main__block behavior.
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-5774
Changes in this PR
test/test_daemon.pywith 13 unit tests covering_popen_wait,_silence_resource_warning,_spawn,_spawn_daemon_double_popen, and_spawn_daemonon both Unix and WindowsFileNotFoundErrorwarnings, double-Popen intermediate process mechanics, and thesys.executablefallback pathDETACHED_PROCESSflag, devnull stdio redirection, and the constant value 0x00000008TestMainBlockverifying the script exits with code 0 when run directlyTest Plan
Checklist
Checklist for Author
Checklist for Reviewer