On this page
article
Pytest Fixture
Share test setup with fixtures.
Category: pytest
Problem
Share test setup with fixtures.
Solution
@pytest.fixture
def client():
return TestClient(app)
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path