Skip to content

test: raise magics test coverage to 95% - #465

Merged
blink1073 merged 4 commits into
Calysto:mainfrom
blink1073:increase-magics-test-coverage
Jul 28, 2026
Merged

test: raise magics test coverage to 95%#465
blink1073 merged 4 commits into
Calysto:mainfrom
blink1073:increase-magics-test-coverage

Conversation

@blink1073

Copy link
Copy Markdown
Contributor

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

  • Added tests exercising previously-uncovered branches (error paths, edge cases, and register_ipython_magics closures) across: brain_magic, conversation_magic, pipe_magic, include_magic, dot_magic, download_magic, scheme_magic, jigsaw_magic, processing_magic, shell_magic, magic_magic, and blockly_magic.
  • 9 of the 12 touched magic modules are now at 100% coverage.

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. Ran just typing and just pre-commit — both pass clean.

AI usage

  • Some or all of the content of this PR was generated by AI.
  • The human author has carefully reviewed this PR and run this code.
  • AI tools and models used: Claude Code (Claude Sonnet 5)

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%.
blink1073 and others added 3 commits July 27, 2026 14:41
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.
@blink1073
blink1073 merged commit 2a51dd9 into Calysto:main Jul 28, 2026
24 checks passed
@blink1073
blink1073 deleted the increase-magics-test-coverage branch July 28, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant