Skip to content

Feature: Fixture and conftest.py support #105

@hughhan1

Description

@hughhan1

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

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