Skip to content

Commit 9fcdf5f

Browse files
committed
Import from django.test not django.test.client
Import from the documented location. Plus it's shorter.
1 parent 9eab641 commit 9fcdf5f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

pytest_django/fixtures.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
if TYPE_CHECKING:
2828
import django
29+
import django.test
2930

3031

3132
_DjangoDbDatabases = Optional[Union[Literal["__all__"], Iterable[str]]]
@@ -393,21 +394,21 @@ def django_db_serialized_rollback(
393394

394395

395396
@pytest.fixture()
396-
def client() -> django.test.client.Client:
397+
def client() -> django.test.Client:
397398
"""A Django test client instance."""
398399
skip_if_no_django()
399400

400-
from django.test.client import Client
401+
from django.test import Client
401402

402403
return Client()
403404

404405

405406
@pytest.fixture()
406-
def async_client() -> django.test.client.AsyncClient:
407+
def async_client() -> django.test.AsyncClient:
407408
"""A Django test async client instance."""
408409
skip_if_no_django()
409410

410-
from django.test.client import AsyncClient
411+
from django.test import AsyncClient
411412

412413
return AsyncClient()
413414

@@ -462,31 +463,31 @@ def admin_user(
462463
def admin_client(
463464
db: None,
464465
admin_user,
465-
) -> django.test.client.Client:
466+
) -> django.test.Client:
466467
"""A Django test client logged in as an admin user."""
467-
from django.test.client import Client
468+
from django.test import Client
468469

469470
client = Client()
470471
client.force_login(admin_user)
471472
return client
472473

473474

474475
@pytest.fixture()
475-
def rf() -> django.test.client.RequestFactory:
476+
def rf() -> django.test.RequestFactory:
476477
"""RequestFactory instance"""
477478
skip_if_no_django()
478479

479-
from django.test.client import RequestFactory
480+
from django.test import RequestFactory
480481

481482
return RequestFactory()
482483

483484

484485
@pytest.fixture()
485-
def async_rf() -> django.test.client.AsyncRequestFactory:
486+
def async_rf() -> django.test.AsyncRequestFactory:
486487
"""AsyncRequestFactory instance"""
487488
skip_if_no_django()
488489

489-
from django.test.client import AsyncRequestFactory
490+
from django.test import AsyncRequestFactory
490491

491492
return AsyncRequestFactory()
492493

tests/test_django_settings_module.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ def test_django_settings_configure(
216216
import pytest
217217
218218
from django.conf import settings
219-
from django.test.client import RequestFactory
220-
from django.test import TestCase
219+
from django.test import RequestFactory, TestCase
221220
from django.contrib.auth.models import User
222221
223222
def test_access_to_setting():

tests/test_fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from django.conf import settings as real_settings
1414
from django.core import mail
1515
from django.db import connection, transaction
16-
from django.test.client import AsyncClient, AsyncRequestFactory, Client, RequestFactory
16+
from django.test import AsyncClient, AsyncRequestFactory, Client, RequestFactory
1717
from django.utils.encoding import force_str
1818

1919
from .helpers import DjangoPytester

0 commit comments

Comments
 (0)