Created
May 28, 2016 03:56
-
-
Save bengolder/c9dc7006f9d6b4d17d5af5465115df73 to your computer and use it in GitHub Desktop.
A useful Django test assertion for testing auth based on http://stackoverflow.com/questions/5660952/test-that-user-was-logged-in-successfully
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from django.contrib import auth | |
class BaseAuthTestCase(TestCase): | |
def assertLoggedInAs(self, user): | |
client_user = auth.get_user(self.client) | |
self.assertEqual(client_user, user) | |
assert client_user.is_authenticated() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment