mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-11 04:07:48 +03:00
Merge pull request #2497 from pydanny/clean-request-factory-fixture
Remove request_factory fixture, use the rf one from pytest-django
This commit is contained in:
commit
c7a5dd6725
|
@ -1,5 +1,4 @@
|
|||
import pytest
|
||||
from django.test import RequestFactory
|
||||
|
||||
from {{ cookiecutter.project_slug }}.users.models import User
|
||||
from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory
|
||||
|
@ -13,8 +12,3 @@ def media_storage(settings, tmpdir):
|
|||
@pytest.fixture
|
||||
def user() -> User:
|
||||
return UserFactory()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def request_factory() -> RequestFactory:
|
||||
return RequestFactory()
|
||||
|
|
|
@ -16,18 +16,18 @@ class TestUserUpdateView:
|
|||
https://github.com/pytest-dev/pytest-django/pull/258
|
||||
"""
|
||||
|
||||
def test_get_success_url(self, user: User, request_factory: RequestFactory):
|
||||
def test_get_success_url(self, user: User, rf: RequestFactory):
|
||||
view = UserUpdateView()
|
||||
request = request_factory.get("/fake-url/")
|
||||
request = rf.get("/fake-url/")
|
||||
request.user = user
|
||||
|
||||
view.request = request
|
||||
|
||||
assert view.get_success_url() == f"/users/{user.username}/"
|
||||
|
||||
def test_get_object(self, user: User, request_factory: RequestFactory):
|
||||
def test_get_object(self, user: User, rf: RequestFactory):
|
||||
view = UserUpdateView()
|
||||
request = request_factory.get("/fake-url/")
|
||||
request = rf.get("/fake-url/")
|
||||
request.user = user
|
||||
|
||||
view.request = request
|
||||
|
@ -36,9 +36,9 @@ class TestUserUpdateView:
|
|||
|
||||
|
||||
class TestUserRedirectView:
|
||||
def test_get_redirect_url(self, user: User, request_factory: RequestFactory):
|
||||
def test_get_redirect_url(self, user: User, rf: RequestFactory):
|
||||
view = UserRedirectView()
|
||||
request = request_factory.get("/fake-url")
|
||||
request = rf.get("/fake-url")
|
||||
request.user = user
|
||||
|
||||
view.request = request
|
||||
|
|
Loading…
Reference in New Issue
Block a user