Add tests for Error_display, do_execute_meta, get_magic_args, display, and process_metakernel classes#327
Merged
blink1073 merged 2 commits intoCalysto:mainfrom Feb 28, 2026
Merged
Conversation
….py, and process_metakernel classes - test_metakernel.py: direct unit tests for Error_display (string, non-string, mixed, redirect_to_log), do_execute_meta (EvalKernel and base MetaKernel), and get_magic_args (no magic, line magic, no-args magic, unknown magic) - test_display.py: tests for display() and clear_output() both with and without an active MetaKernel instance - test_process_metakernel_classes.py: tests for all classes in process_metakernel.py — TextOutput, ProcessMetaKernel (banner, language_version, do_execute_direct, check_exitcode, makeWrapper, do_shutdown, restart_kernel), BashKernel (banner fetching and caching), and DynamicKernel (attributes and makeWrapper)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #327 +/- ##
==========================================
+ Coverage 74.94% 77.80% +2.86%
==========================================
Files 51 51
Lines 2794 2794
Branches 388 388
==========================================
+ Hits 2094 2174 +80
+ Misses 560 484 -76
+ Partials 140 136 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- tests/utils.py: make get_kernel() generic via @overload so callers typed with a subclass get the subclass type back, resolving attr-defined errors for ProcessMetaKernel-specific attributes - test_process_metakernel_classes.py: add cast(MagicMock, ...) for mock method access on typed REPLWrapper attributes; remove stale type: ignore comments; guard wrapper access with assert is not None - test_metakernel.py: add Any import, parametrize list annotations, annotate get_magic_args result as Any to allow tuple unpack - test_display.py: use type: ignore[method-assign] on mock assignments (setattr is disallowed by ruff B010 when the attribute name is a constant literal)
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.
Summary
test_metakernel.py: direct unit tests forError_display(string, non-string, mixed args,redirect_to_log),do_execute_meta(bothEvalKerneland baseMetaKernel), andget_magic_args(no magic, line magic, no-args magic, unknown magic)test_display.py: new module testingdisplay.display()anddisplay.clear_output()with and without an activeMetaKernelinstance, verifying correct delegation to eitherkernel.Display/kernel.clear_outputor the IPython fallbackstest_process_metakernel_classes.py: new module covering all classes inprocess_metakernel.py—TextOutput,ProcessMetaKernel(banner,language_version,do_execute_directall code paths,check_exitcode,makeWrapper,do_shutdown,restart_kernel),BashKernel(banner content and instance-level caching), andDynamicKernel(attribute initialisation andmakeWrapperargument forwarding)Test plan
just test)ruff format/ruff check)