Skip to content

feat(core): per-test isolation marker (global barrier) #147

Description

@renaudcepre

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions