You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tests: stop re-importing pcapkit before every test (purge_modules dominates suite time) #1065
Is your feature request related to a problem? Please describe.
The #1062 audit found that 1,564 tests across 119 modules (243 call sites) call purge_modules(['pcapkit']) in setUp. That forces a fresh import of pcapkit (329 modules, about 0.67 s) before each of those tests. In the audit, disabling the purge cut pytest time on 192 modules from 1,714 s to 253 s (−85%).
I spot-checked one module on main: tests/protocols/application/test_http_unit.py gave 65 passed / 395 subtests in 77.38 s with the purge, and 0.29 s with it stubbed out.
Describe the solution you'd like
Re-import only where isolation is actually needed. Eight modules fail or hang without the purge: enum_builtin_parity, fields_collections, fields_field, pcapng_unit, dispatch_reachability, tcp_http_dispatch, test_support_helpers, and foundation/test_extraction (hangs). Candidate approaches:
purge once per class in setUpClass;
purge only in the modules that need it;
find and fix the state those eight depend on.
The plain-unittest leg's cross-generation check (#981) must keep catching what it catches today.
Describe alternatives you've considered
Deleting tests: #1062 found that the genuinely redundant ones would save about 2 s.
Additional context
Raw data is in the #1062 audit (/tmp/audit1062/ on the audit host). Related: #1052.
Proceeding: the #1062 ruling bundles the five audit trims into this work. On approach, the default taken is to purge only where isolation is actually needed: once per class, or only in the modules measured to depend on it. The #981 cross-generation check in the plain-unittest leg must still catch what it catches today. A worker is on it; say if you'd rather a different approach.
Activity
JarryShaw commentedon Oct 6, 2026
Proceeding: the #1062 ruling bundles the five audit trims into this work. On approach, the default taken is to purge only where isolation is actually needed: once per class, or only in the modules measured to depend on it. The #981 cross-generation check in the plain-unittest leg must still catch what it catches today. A worker is on it; say if you'd rather a different approach.
JarryShaw commentedon Oct 6, 2026
And the re-import fix is accepted. Taking your recommendations.
test: re-import pcapkit only where isolation needs it (#1065)
test: re-import pcapkit only where isolation needs it (#1065)
test: re-import pcapkit only where isolation needs it (#1065) (#1070)