mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-10 06:54:52 +03:00
Update pytest style to match update Ruff rules
This commit is contained in:
parent
5e1377d860
commit
a5e6a1521f
|
@ -9,6 +9,6 @@ def _media_storage(settings, tmpdir) -> None:
|
||||||
settings.MEDIA_ROOT = tmpdir.strpath
|
settings.MEDIA_ROOT = tmpdir.strpath
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture
|
||||||
def user(db) -> User:
|
def user(db) -> User:
|
||||||
return UserFactory()
|
return UserFactory()
|
||||||
|
|
|
@ -56,7 +56,7 @@ class TestUserAdmin:
|
||||||
response = admin_client.get(url)
|
response = admin_client.get(url)
|
||||||
assert response.status_code == HTTPStatus.OK
|
assert response.status_code == HTTPStatus.OK
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture
|
||||||
def _force_allauth(self, settings):
|
def _force_allauth(self, settings):
|
||||||
settings.DJANGO_ADMIN_FORCE_ALLAUTH = True
|
settings.DJANGO_ADMIN_FORCE_ALLAUTH = True
|
||||||
# Reload the admin module to apply the setting change
|
# Reload the admin module to apply the setting change
|
||||||
|
@ -65,7 +65,7 @@ class TestUserAdmin:
|
||||||
with contextlib.suppress(admin.sites.AlreadyRegistered): # type: ignore[attr-defined]
|
with contextlib.suppress(admin.sites.AlreadyRegistered): # type: ignore[attr-defined]
|
||||||
reload(users_admin)
|
reload(users_admin)
|
||||||
|
|
||||||
@pytest.mark.django_db()
|
@pytest.mark.django_db
|
||||||
@pytest.mark.usefixtures("_force_allauth")
|
@pytest.mark.usefixtures("_force_allauth")
|
||||||
def test_allauth_login(self, rf, settings):
|
def test_allauth_login(self, rf, settings):
|
||||||
request = rf.get("/fake-url")
|
request = rf.get("/fake-url")
|
||||||
|
|
|
@ -6,7 +6,7 @@ from {{ cookiecutter.project_slug }}.users.models import User
|
||||||
|
|
||||||
|
|
||||||
class TestUserViewSet:
|
class TestUserViewSet:
|
||||||
@pytest.fixture()
|
@pytest.fixture
|
||||||
def api_rf(self) -> APIRequestFactory:
|
def api_rf(self) -> APIRequestFactory:
|
||||||
return APIRequestFactory()
|
return APIRequestFactory()
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.core.management import call_command
|
||||||
from {{ cookiecutter.project_slug }}.users.models import User
|
from {{ cookiecutter.project_slug }}.users.models import User
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db()
|
@pytest.mark.django_db
|
||||||
class TestUserManager:
|
class TestUserManager:
|
||||||
def test_create_user(self):
|
def test_create_user(self):
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
|
@ -37,7 +37,7 @@ class TestUserManager:
|
||||||
assert user.username is None
|
assert user.username is None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db()
|
@pytest.mark.django_db
|
||||||
def test_createsuperuser_command():
|
def test_createsuperuser_command():
|
||||||
"""Ensure createsuperuser command works with our custom manager."""
|
"""Ensure createsuperuser command works with our custom manager."""
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
|
|
|
@ -10,7 +10,7 @@ def test_swagger_accessible_by_admin(admin_client):
|
||||||
assert response.status_code == HTTPStatus.OK
|
assert response.status_code == HTTPStatus.OK
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db()
|
@pytest.mark.django_db
|
||||||
def test_swagger_ui_not_accessible_by_normal_user(client):
|
def test_swagger_ui_not_accessible_by_normal_user(client):
|
||||||
url = reverse("api-docs")
|
url = reverse("api-docs")
|
||||||
response = client.get(url)
|
response = client.get(url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user