mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 01:49:50 +03:00
Ensure test de-monkeypatches auth on failure
This commit is contained in:
parent
2cd5d58e3b
commit
24c18fc3d6
|
@ -533,11 +533,13 @@ class BasicAuthenticationUnitTests(TestCase):
|
|||
is_active = False
|
||||
old_authenticate = authentication.authenticate
|
||||
authentication.authenticate = lambda **kwargs: MockUser()
|
||||
auth = authentication.BasicAuthentication()
|
||||
with pytest.raises(exceptions.AuthenticationFailed) as error:
|
||||
auth.authenticate_credentials('foo', 'bar')
|
||||
assert 'User inactive or deleted.' in str(error)
|
||||
authentication.authenticate = old_authenticate
|
||||
try:
|
||||
auth = authentication.BasicAuthentication()
|
||||
with pytest.raises(exceptions.AuthenticationFailed) as error:
|
||||
auth.authenticate_credentials('foo', 'bar')
|
||||
assert 'User inactive or deleted.' in str(error)
|
||||
finally:
|
||||
authentication.authenticate = old_authenticate
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF=__name__,
|
||||
|
|
Loading…
Reference in New Issue
Block a user