apte has max_concurrency to cap how many tests sharing a fixture run at once,
but no way to say "this test needs the process to itself, pause everything else
while it runs".
Surfaced porting httpx's suite: test_httpcore_lazy_loading mutates and asserts
on global sys.modules (it deletes httpcore, then asserts it isn't re-imported
yet). Under -n > 1 a concurrent sibling doing an HTTP request re-imports
httpcore between the delete and the assert, so it races. max_concurrency=1
cannot fix it: the racing test shares no fixture with it, so nothing constrains
it. The only correct handling today is -n 1 (serializes the whole suite) or
skipping the test under concurrency.
Same class of problem as tests touching os.environ or warnings filters
(global, process-wide mutable state).
Proposed: a marker like @suite.test(isolated=True) that acts as a global
barrier (drain in-flight tests, run this one alone, then resume). Lets a suite
keep parallelism while still supporting the handful of tests that legitimately
need a quiet process.
Doc note while we're at it: max_concurrency reads as a global limit but is
per-fixture. Worth clarifying in the docs.
apte has
max_concurrencyto cap how many tests sharing a fixture run at once,but no way to say "this test needs the process to itself, pause everything else
while it runs".
Surfaced porting httpx's suite:
test_httpcore_lazy_loadingmutates and assertson global
sys.modules(it deletes httpcore, then asserts it isn't re-importedyet). Under
-n > 1a concurrent sibling doing an HTTP request re-importshttpcore between the delete and the assert, so it races.
max_concurrency=1cannot fix it: the racing test shares no fixture with it, so nothing constrains
it. The only correct handling today is
-n 1(serializes the whole suite) orskipping the test under concurrency.
Same class of problem as tests touching
os.environorwarningsfilters(global, process-wide mutable state).
Proposed: a marker like
@suite.test(isolated=True)that acts as a globalbarrier (drain in-flight tests, run this one alone, then resume). Lets a suite
keep parallelism while still supporting the handful of tests that legitimately
need a quiet process.
Doc note while we're at it:
max_concurrencyreads as a global limit but isper-fixture. Worth clarifying in the docs.