Skip to content

Review pytest fixtures scopes #635

@VKTB

Description

@VKTB

Arises from: ral-facilities/ldap-jwt-auth#283

Unless a scope is specified for a pytest fixture, it means that it is created and destroyed in each test. The above PR sets the scope of the fixture_test_client fixture to package so that FastAPI's TestClient object can be created before any e2e tests are run and destroyed after all the tests run. We have the same fixture in this project that will need updating but it's also worth reviewing other fixtures while at it.

@pytest.fixture(name="test_client")
def fixture_test_client() -> TestClient:
"""
Fixture for creating a test client for the application.
:return: The test client.
"""
return TestClient(app, headers={"Authorization": f"Bearer {VALID_ACCESS_TOKEN}"})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions