Patch client test fixture with useful login method.
This removes django-testclient-extensions because it doesn't compatible with django 1.7.remotes/origin/enhancement/email-actions
parent
c1b011fa99
commit
59c7478075
|
@ -41,15 +41,13 @@ class PartialMethodCaller:
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def client():
|
def client():
|
||||||
from django.test.client import Client
|
from django.test.client import Client
|
||||||
from django.test.client import MULTIPART_CONTENT
|
|
||||||
|
|
||||||
class _Client(Client):
|
class _Client(Client):
|
||||||
def login(self, user=None, backend="django.contrib.auth.backends.ModelBackend", **credentials):
|
def login(self, user=None, backend="django.contrib.auth.backends.ModelBackend", **credentials):
|
||||||
if user is None:
|
if user is None:
|
||||||
return super().login(**credentials)
|
return super().login(**credentials)
|
||||||
|
|
||||||
# This will be changed on django1.7 branch with other location
|
with mock.patch('django.contrib.auth.authenticate') as authenticate:
|
||||||
with mock.patch('django.test.client.authenticate') as authenticate:
|
|
||||||
user.backend = backend
|
user.backend = backend
|
||||||
authenticate.return_value = user
|
authenticate.return_value = user
|
||||||
return super().login(**credentials)
|
return super().login(**credentials)
|
||||||
|
|
Loading…
Reference in New Issue