test: raise magics test coverage to 95% - #465
Merged
Merged
Conversation
Adds tests for register_ipython_magics closures and previously-untested error/edge-case branches across brain, conversation, pipe, include, dot, download, scheme, jigsaw, processing, shell, magic, and blockly magics. Overall magics coverage rises from 84% to 95%.
test_start_process_falls_back_to_sh previously let start_process() actually spawn a real "sh" process. On Ubuntu CI runners /bin/sh is dash, which doesn't understand pexpect's --rcfile flag, causing an immediate EOF and test failure. Mock bash() the same way the powershell fallback test already does, so the test only verifies branch selection instead of depending on the host's /bin/sh.
test_start_process_uses_powershell_on_windows monkeypatched os.name directly, but sm.os is the real stdlib os module (a process-wide singleton), so this temporarily corrupted os.name for everything else running during the test. On the Test SDist CI job, pytest's own internal use of pathlib.Path while reporting that test's result hit this corrupted state and tried to instantiate WindowsPath on Linux, crashing the whole pytest run with a NotImplementedError. Replace the module-level `os` reference with a minimal fake object instead of mutating the real os module.
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.
References
None
Description
Increases test coverage of the
metakernel/magics/package, which was at 84%, up to 95%. No production code was changed — this PR is test-only.Changes
register_ipython_magicsclosures) across:brain_magic,conversation_magic,pipe_magic,include_magic,dot_magic,download_magic,scheme_magic,jigsaw_magic,processing_magic,shell_magic,magic_magic, andblockly_magic.Backwards-incompatible changes
None
Testing
Ran the full test suite (
poetry run pytest tests/) — 541 passed, 13 skipped (pre-existing platform/network/dependency skips), 0 failed. Ranjust typingandjust pre-commit— both pass clean.AI usage