Skip to content

Instantly share code, notes, and snippets.

@hynek
Created October 6, 2011 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hynek/1266898 to your computer and use it in GitHub Desktop.
Save hynek/1266898 to your computer and use it in GitHub Desktop.
A decorator for Django tests that logs you in before running a test.
def login_first(test):
"""Decorator offering convenience login for tests that require it."""
def _login(self):
self.client.login(
username='testusername',
password='testpassword')
return test(self)
return _login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment