Remove request_factory fixture, use the rf one from pytest-django

This commit is contained in:
Bruno Alla 2020-03-17 19:00:55 +00:00
parent 83f28a592c
commit 1e612c4cfb
2 changed files with 6 additions and 12 deletions

View File

@ -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()

View File

@ -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