Created
August 28, 2012 20:41
-
-
Save konradhalas/3504037 to your computer and use it in GitHub Desktop.
UserFactory with raw_password
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
class UserFactory(factory.Factory): | |
password = 'test' | |
@classmethod | |
def _prepare(cls, create, **kwargs): | |
password = kwargs.pop('password', None) | |
user = super(UserFactory, cls)._prepare(create, **kwargs) | |
if password: | |
user.raw_password = password | |
user.set_password(password) | |
if create: | |
user.save() | |
return user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment