mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 01:26:53 +03:00
Update pytest (#6768)
* Update pytest to 5.x * Ensure test de-monkeypatches auth on failure * Fix pytest.raises compat issue
This commit is contained in:
parent
82c2b5c3e7
commit
c04d6eac43
|
@ -1,4 +1,4 @@
|
||||||
# Pytest for running the tests.
|
# Pytest for running the tests.
|
||||||
pytest>=4.5.0,<4.6
|
pytest>=5.0,<5.1
|
||||||
pytest-django>=3.4.8,<3.5
|
pytest-django>=3.5.1,<3.6
|
||||||
pytest-cov>=2.7.1
|
pytest-cov>=2.7.1
|
||||||
|
|
|
@ -533,11 +533,13 @@ class BasicAuthenticationUnitTests(TestCase):
|
||||||
is_active = False
|
is_active = False
|
||||||
old_authenticate = authentication.authenticate
|
old_authenticate = authentication.authenticate
|
||||||
authentication.authenticate = lambda **kwargs: MockUser()
|
authentication.authenticate = lambda **kwargs: MockUser()
|
||||||
auth = authentication.BasicAuthentication()
|
try:
|
||||||
with pytest.raises(exceptions.AuthenticationFailed) as error:
|
auth = authentication.BasicAuthentication()
|
||||||
auth.authenticate_credentials('foo', 'bar')
|
with pytest.raises(exceptions.AuthenticationFailed) as exc_info:
|
||||||
assert 'User inactive or deleted.' in str(error)
|
auth.authenticate_credentials('foo', 'bar')
|
||||||
authentication.authenticate = old_authenticate
|
assert 'User inactive or deleted.' in str(exc_info.value)
|
||||||
|
finally:
|
||||||
|
authentication.authenticate = old_authenticate
|
||||||
|
|
||||||
|
|
||||||
@override_settings(ROOT_URLCONF=__name__,
|
@override_settings(ROOT_URLCONF=__name__,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user