From 1560bf7112652cbbc06d6d58031cd268d293ee13 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 19 Feb 2018 18:00:21 +0100 Subject: [PATCH] Fix incompatibility with recent factory_boy postgeneration. --- atmo/users/factories.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atmo/users/factories.py b/atmo/users/factories.py index 722d4885..f967b5a1 100644 --- a/atmo/users/factories.py +++ b/atmo/users/factories.py @@ -4,6 +4,7 @@ import factory from django.contrib.auth.models import User, Group +from django.contrib.auth.hashers import make_password class GroupFactory(factory.django.DjangoModelFactory): @@ -17,11 +18,16 @@ class UserFactory(factory.django.DjangoModelFactory): username = factory.Sequence(lambda n: 'user%s' % n) first_name = factory.Sequence(lambda n: "user %03d" % n) email = 'test@example.com' - password = factory.PostGenerationMethodCall('set_password', 'password') class Meta: model = User + @factory.post_generation + def password(self, create, extracted, **kwargs): + if not create: + return + return make_password('password') + @factory.post_generation def groups(self, create, extracted, **kwargs): if not create: