Django TypeError: force_authenticate() missing 1 required positional argument: 'self'

Viewed 877

Test case setUp() that first creates a user and the try's to force authenticate the user but a wired error occurs...

TypeError: force_authenticate() missing 1 required positional argument: 'self'

class PrivateUserApiTest(TestCase):
    """ Test API that require authentication """

    def setUp(self):
        self.user = create_user(
            email="test@test.com",
            password="testpass",
            name="testName"
        )
        print(self.user)
        self.client = APIClient
        self.client.force_authenticate(user=self.user) # <-- 
1 Answers

as @BhavyaParikh said, instead of this:

self.client = APIClient

do this:

self.client = APIClient()
Related