Repository navigation
test: keep the per-class pcapkit import in 12 classes that re-imported per test (#1538) - #1557
Merged
Merged
Conversation
…d per test (#1538) - 12 classes in 7 modules call reimport_once_per_class() in setUp and purged pcapkit in tearDown. tearDown runs before _keep_lazy_imports records the class's import, so every test re-imported (#1070 converted setUp only). Drop the tearDown purge. - SchemaMetaAbcCacheTests and DefaultDescriptorResolutionTests use restore=True, which keeps their documented confinement (the ABC-cache reset, the reloaded Raw) at class scope; their comments are rewritten to match. - test_dispatch_keys_did_not_move_with_the_modules takes a fresh import via isolate_modules(): a dispatch hit writes the resolved class back into the registry, so on the shared import it failed whenever a parsing test ran first. - New tests/project/test_per_class_import_guard.py AST-scans tests/ for the pairing. On main it fails and lists the 12 classes. The 7 modules in one serial pytest process: 71.8 s -> 15.4 s (mean of 3), with 68 passed and 63 subtests both times and pcapkit coverage unchanged.
Owner
Author
|
Verdict: GOOD TO GO at
Not blocking:
|
Contributor
|
Coverage: 90.02% (unit tier, Python 3.14,
Per-file detail: the |
5 of 13 tasks
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.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the change (affected legs only, listed below; the full suite was not run locally)Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
Refs #1538 (P2). Twelve classes in seven modules, 66 tests, called
reimport_once_per_class()insetUpand then purgedpcapkitintearDown. That emptied the class's import before_keep_lazy_importscould record it, so every test re-imported the package. This PR drops thetearDownpurge. The proposal's 13 classes and 72 tests counts are wrong: an AST scan ofmainfinds 12 and 66.test_const_enum_builtin_parityis untouched.restore=True, so their documented confinement (the ABC-cache reset, the reloadedRaw) holds at class scope. Mutation tests give the same failing tests before and after: reverting Schema subclasses share one ABCMeta cache on Python <=3.10, so isinstance/issubclass return whichever answer was asked first #439 (type.__new__) fails the same 5, and a pre-Memoise the default ModuleDescriptor on a registry miss, instead of re-resolving it per frame (from #563) #574klassfails the same 1. A perf: Optimize Protocol extraction by caching dynamically imported modules in ProtocolBase #563-style memo fails 2 here against 1 on main.test_dispatch_keys_did_not_move_with_the_modulesfailed on the shared import whenever a parsing test ran first: reverse order gave 2 failures, and so did 3 of 3 shuffles. The per-test purge had been hiding this. That test now takesisolate_modules(self), and 17 orderings pass.tests/project/test_per_class_import_guard.pyfails onmain, listing the 12 classes. It has an allowlist (empty) that is enforced both ways, and it does not match narrow purges such as thetest_scapy_unitone.Measured, serial pytest, mean of 3:
Both runs gave 68 passed and 63 subtests. Line and branch coverage of
pcapkitis identical (27,861 lines, 1,307 branches).Plain unittest, one run each:
run_unittest_leg.py protocols --exclude protocols/internetrun_unittest_leg.py utilitiesBoth legs had 0 failures and 0 errors. These figures are lower bounds, because the baseline was a non-git tree that skipped 57 git-dependent root tests.
CI estimate, not measured: about 2.4-3.7 runner-minutes per PR, using #1538's unverified 1.4-2.2x xdist factor and its x1.57 coverage leg.