From 58151b4bde8a28d3ab4d93267534517ba104ce24 Mon Sep 17 00:00:00 2001 From: mentix02 Date: Thu, 11 Jun 2020 17:02:00 -0700 Subject: [PATCH] Added abc.abstractmethod decorator to BaseAuthentication.authenticate and fixed tests for the same. --- rest_framework/authentication.py | 1 + tests/authentication/test_authentication.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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):