diff --git a/tests/auth_tests/test_auth_backends_deprecation.py b/tests/auth_tests/test_auth_backends_deprecation.py
index 765d87b..398d34c 100644
a
|
b
|
class NoRequestBackend:
|
10 | 10 | pass |
11 | 11 | |
12 | 12 | |
| 13 | class RequestNotPositionArgBackend: |
| 14 | def authenticate(self, username, password, request): |
| 15 | pass |
| 16 | |
| 17 | |
13 | 18 | class AcceptsRequestBackendTest(SimpleTestCase): |
14 | 19 | """ |
15 | 20 | A deprecation warning is shown for backends that have an authenticate() |
16 | 21 | method without a request parameter. |
17 | 22 | """ |
18 | 23 | no_request_backend = '%s.NoRequestBackend' % __name__ |
| 24 | request_not_positional_backend = '%s.RequestNotPositionArgBackend' % __name__ |
19 | 25 | |
20 | 26 | @override_settings(AUTHENTICATION_BACKENDS=[no_request_backend]) |
21 | 27 | def test_no_request_deprecation_warning(self): |
… |
… |
class AcceptsRequestBackendTest(SimpleTestCase):
|
28 | 34 | "Update %s.authenticate() to accept a positional `request` " |
29 | 35 | "argument." % self.no_request_backend |
30 | 36 | ) |
| 37 | |
| 38 | @override_settings(AUTHENTICATION_BACKENDS=[request_not_positional_backend]) |
| 39 | def test_request_keyword_arg_deprecation_warning(self): |
| 40 | with warnings.catch_warnings(record=True) as warns: |
| 41 | warnings.simplefilter('always') |
| 42 | authenticate(username='test', password='test', request=object()) |
| 43 | self.assertEqual(len(warns), 1) |
| 44 | self.assertEqual( |
| 45 | str(warns[0].message), |
| 46 | "In %s.authenticate(), move the `request` keyword arugment to the " |
| 47 | "first positional argument." % self.request_not_positional_backend |
| 48 | ) |