tests/cli/test_main.py writes to sys.modules by hand and never restores, so pairing it with tests/project/test_public_api.py produces 10 errors. Measured identically on origin/main and on #686's branch, so it is neither caused nor cured by that change.
The shape
Same class of defect as #674: a test binds stand-ins into the pcapkit region of sys.modules and leaves them there, so a later test that introspects the real package gets the stand-ins. #674's fix (#686) covers the loaders in tests/_support.py; this file bypasses them entirely with its own writes, so it is untouched by that work.
Why it is normally invisible
The same masking as #674: tests/conftest.py:95's autouse restore_module_table fixture repairs the region after every test, so the symptom does not appear under a normal pytest run. It surfaces under --noconftest, under the stdlib unittest runner, or any route that does not load that conftest.
Worth noting that tests/conftest.py names this very file as the witness for #662's guard — so the guard is documented against the file that still needs the underlying fix.
Suggested direction
Route its sys.modules writes through the restoring helpers tests/_support.py now provides (restore_modules_after, or isolate_modules) rather than hand-rolling them, so the restoration is owed and discharged in one place. A regression assertion that the pcapkit region is unchanged after the module's tests would pin it.
Provenance
Found by #686's worker while auditing leakage for #674 and deliberately left out of that PR — different file, different mechanism, and fixing it there would have widened a test-infrastructure change into the CLI tests. The 10-error measurement is its figure; I have not independently re-run it.
tests/cli/test_main.pywrites tosys.modulesby hand and never restores, so pairing it withtests/project/test_public_api.pyproduces 10 errors. Measured identically onorigin/mainand on #686's branch, so it is neither caused nor cured by that change.The shape
Same class of defect as #674: a test binds stand-ins into the
pcapkitregion ofsys.modulesand leaves them there, so a later test that introspects the real package gets the stand-ins. #674's fix (#686) covers the loaders intests/_support.py; this file bypasses them entirely with its own writes, so it is untouched by that work.Why it is normally invisible
The same masking as #674:
tests/conftest.py:95's autouserestore_module_tablefixture repairs the region after every test, so the symptom does not appear under a normal pytest run. It surfaces under--noconftest, under the stdlibunittestrunner, or any route that does not load that conftest.Worth noting that
tests/conftest.pynames this very file as the witness for #662's guard — so the guard is documented against the file that still needs the underlying fix.Suggested direction
Route its
sys.moduleswrites through the restoring helperstests/_support.pynow provides (restore_modules_after, orisolate_modules) rather than hand-rolling them, so the restoration is owed and discharged in one place. A regression assertion that thepcapkitregion is unchanged after the module's tests would pin it.Provenance
Found by #686's worker while auditing leakage for #674 and deliberately left out of that PR — different file, different mechanism, and fixing it there would have widened a test-infrastructure change into the CLI tests. The 10-error measurement is its figure; I have not independently re-run it.