pytest-dev / pytest-django

A Django plugin for pytest.
https://pytest-django.readthedocs.io/
Other
1.4k stars 345 forks source link

fixtures: provide per-scope fixtures for unblocking database access #1162

Closed m000 closed 3 weeks ago

m000 commented 3 weeks ago

Allow the convenience of db fixture for all fixture scopes.

The db fixture is very convenient when writing fixtures that create objects. However, for non function-scoped fixtures using db is not possible. This PR adds db_<scope> fixtures that can be used to the same effect as db when creating fixtures that use other scopes.

m000 commented 3 weeks ago

NVM. For anyone attempting the same thing, this has side-effects: by enabling database access from a wider scope, (of course) ALL tests in that scope will be allowed database access.