Skip to content

Commit 606617b

Browse files
committed
Prefix all fixtures with "django_"
1 parent f55c709 commit 606617b

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

Diff for: pytest_django/fixtures.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
__all__ = [
1717
"django_db_setup",
18-
"db",
19-
"transactional_db",
18+
"django_db",
19+
"django_transactional_db",
2020
"django_db_reset_sequences",
21-
"admin_user",
21+
"django_admin_user",
2222
"django_user_model",
2323
"django_username_field",
24-
"client",
25-
"admin_client",
26-
"rf",
27-
"settings",
28-
"live_server",
24+
"django_client",
25+
"django_admin_client",
26+
"django_rf",
27+
"django_settings",
28+
"django_live_server",
2929
"_live_server_helper",
3030
"django_assert_num_queries",
3131
"django_assert_max_num_queries",
@@ -157,7 +157,7 @@ def _disable_native_migrations():
157157

158158

159159
@pytest.fixture(scope="function")
160-
def db(request, django_db_setup, django_db_blocker):
160+
def django_db(request, django_db_setup, django_db_blocker):
161161
"""Require a django test database.
162162
163163
This database will be setup with the default fixtures and will have
@@ -183,7 +183,7 @@ def db(request, django_db_setup, django_db_blocker):
183183

184184

185185
@pytest.fixture(scope="function")
186-
def transactional_db(request, django_db_setup, django_db_blocker):
186+
def django_transactional_db(request, django_db_setup, django_db_blocker):
187187
"""Require a django test database with transaction support.
188188
189189
This will re-initialise the django database for each test and is
@@ -220,7 +220,7 @@ def django_db_reset_sequences(request, django_db_setup, django_db_blocker):
220220

221221

222222
@pytest.fixture()
223-
def client():
223+
def django_client():
224224
"""A Django test client instance."""
225225
skip_if_no_django()
226226

@@ -244,7 +244,7 @@ def django_username_field(django_user_model):
244244

245245

246246
@pytest.fixture()
247-
def admin_user(db, django_user_model, django_username_field):
247+
def django_admin_user(db, django_user_model, django_username_field):
248248
"""A Django admin user.
249249
250250
This uses an existing user with username "admin", or creates a new one with
@@ -267,7 +267,7 @@ def admin_user(db, django_user_model, django_username_field):
267267

268268

269269
@pytest.fixture()
270-
def admin_client(db, admin_user):
270+
def django_admin_client(db, admin_user):
271271
"""A Django test client logged in as an admin user."""
272272
from django.test.client import Client
273273

@@ -277,7 +277,7 @@ def admin_client(db, admin_user):
277277

278278

279279
@pytest.fixture()
280-
def rf():
280+
def django_rf():
281281
"""RequestFactory instance"""
282282
skip_if_no_django()
283283

@@ -320,7 +320,7 @@ def finalize(self):
320320

321321

322322
@pytest.yield_fixture()
323-
def settings():
323+
def django_settings():
324324
"""A Django settings object which restores changes after the testrun"""
325325
skip_if_no_django()
326326

@@ -330,7 +330,7 @@ def settings():
330330

331331

332332
@pytest.fixture(scope="session")
333-
def live_server(request):
333+
def django_live_server(request):
334334
"""Run a live Django server in the background during tests
335335
336336
The address the server is started from is taken from the

Diff for: pytest_django/plugin.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@
2424
from .fixtures import django_db_modify_db_settings # noqa
2525
from .fixtures import django_db_modify_db_settings_xdist_suffix # noqa
2626
from .fixtures import _live_server_helper # noqa
27-
from .fixtures import admin_client # noqa
28-
from .fixtures import admin_user # noqa
29-
from .fixtures import client # noqa
30-
from .fixtures import db # noqa
27+
from .fixtures import django_admin_client # noqa
28+
from .fixtures import django_admin_user # noqa
29+
from .fixtures import django_client # noqa
30+
from .fixtures import django_db # noqa
3131
from .fixtures import django_user_model # noqa
3232
from .fixtures import django_username_field # noqa
33-
from .fixtures import live_server # noqa
33+
from .fixtures import django_live_server # noqa
3434
from .fixtures import django_db_reset_sequences # noqa
35-
from .fixtures import rf # noqa
36-
from .fixtures import settings # noqa
37-
from .fixtures import transactional_db # noqa
35+
from .fixtures import django_rf # noqa
36+
from .fixtures import django_settings
37+
from .fixtures import django_transactional_db # noqa
38+
3839

3940
from .lazy_django import django_settings_is_configured, skip_if_no_django
4041

@@ -44,6 +45,17 @@
4445
import pathlib2 as pathlib
4546

4647

48+
# For backward compatibility.
49+
admin_client = django_admin_client
50+
admin_user = django_admin_user
51+
client = django_client
52+
db = django_db
53+
live_server = django_live_server
54+
rf = django_rf
55+
settings = django_settings
56+
transactional_db = django_transactional_db
57+
58+
4759
SETTINGS_MODULE_ENV = "DJANGO_SETTINGS_MODULE"
4860
CONFIGURATION_ENV = "DJANGO_CONFIGURATION"
4961
INVALID_TEMPLATE_VARS_ENV = "FAIL_INVALID_TEMPLATE_VARS"

0 commit comments

Comments
 (0)