Summary
Explore adding fixture support to rtest's native runner, including conftest.py discovery. This would allow users to define reusable test setup/teardown logic.
Background
rtest currently supports class-level setup_method()/teardown_method() but lacks pytest-style fixtures. After researching how pytest-xdist handles fixtures with parallel workers, we've identified several feasible approaches.
Worker Isolation
Like pytest-xdist, rtest workers are isolated processes. This means:
- Each worker can independently load
conftest.py files
- Fixture resolution happens at runtime in Python, not Rust
- "Session scope" means per-worker-session (same as xdist)
Design Options
Python-Only Implementation
Add fixture support entirely in the Python worker layer:
- Workers walk directory tree to discover
conftest.py files
- Extract
@pytest.fixture decorated functions at runtime
- Resolve fixture dependencies via function signature inspection
- Inject resolved fixtures into test functions
Rust Collection + Python Execution
Rust parses conftest.py files during collection to extract fixture metadata (names, scopes, dependencies), then passes this to workers.
Native rtest Fixtures
Define a new @rtest.fixture decorator with simpler semantics than pytest:
- Explicit scope declaration
- No
request object
- No indirect parametrization
Related
Summary
Explore adding fixture support to rtest's native runner, including
conftest.pydiscovery. This would allow users to define reusable test setup/teardown logic.Background
rtest currently supports class-level
setup_method()/teardown_method()but lacks pytest-style fixtures. After researching how pytest-xdist handles fixtures with parallel workers, we've identified several feasible approaches.Worker Isolation
Like pytest-xdist, rtest workers are isolated processes. This means:
conftest.pyfilesDesign Options
Python-Only Implementation
Add fixture support entirely in the Python worker layer:
conftest.pyfiles@pytest.fixturedecorated functions at runtimeRust Collection + Python Execution
Rust parses
conftest.pyfiles during collection to extract fixture metadata (names, scopes, dependencies), then passes this to workers.Native rtest Fixtures
Define a new
@rtest.fixturedecorator with simpler semantics than pytest:requestobjectRelated
setup_method(),teardown_method(),setUp(),tearDown()