diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index 43950f697..d4f3d8dbb 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -36,6 +36,7 @@ class BaseAuthentication(abc.ABC): All authentication classes should extend BaseAuthentication. """ + @abc.abstractmethod def authenticate(self, request): """ Authenticate the request and return a two-tuple of (user, token). diff --git a/tests/authentication/test_authentication.py b/tests/authentication/test_authentication.py index 4760ea319..20c60f41c 100644 --- a/tests/authentication/test_authentication.py +++ b/tests/authentication/test_authentication.py @@ -537,7 +537,7 @@ class NoAuthenticationClassesTests(TestCase): class BasicAuthenticationUnitTests(TestCase): def test_base_authentication_abstract_method(self): - with pytest.raises(NotImplementedError): + with pytest.raises(TypeError): BaseAuthentication().authenticate({}) def test_basic_authentication_raises_error_if_user_not_found(self):