django-constance icon indicating copy to clipboard operation
django-constance copied to clipboard

pytest fixture scope

Open last-partizan opened this issue 5 years ago • 3 comments

https://github.com/jazzband/django-constance/blob/4e5573ed95c6c4fd2f566e9669f03d4640eb75e9/constance/test/pytest.py#L74

By default pytest fixture has scope="function", so it can not be used with any scope, as mentioned in docs.

last-partizan avatar Aug 06 '20 14:08 last-partizan

@last-partizan unfortunately, the global fixture can have only one scope. So no way to make it universal for any scope. Luckily, a user is still able to override the fixture in the project's conftest.py or any test file like

@pytest.fixture(scope='module')
def override_config(override_config):  # give same name for the custom fixture 
    with override_config(API_URL="/awesome/url/"):
        yield

So i think this issue is more about mentioning that in the documentation rather than fixing fixture.

TamoshaytisV avatar Nov 14 '21 10:11 TamoshaytisV

Yes, it's about mentioning this in documentation.

last-partizan avatar Nov 14 '21 12:11 last-partizan

Can anyone help us with it?

camilonova avatar Dec 15 '21 16:12 camilonova