diff --git a/zds/member/tests/factories.py b/zds/member/tests/factories.py index e38f64683e..e75e4d2e85 100644 --- a/zds/member/tests/factories.py +++ b/zds/member/tests/factories.py @@ -24,6 +24,22 @@ class Meta: is_active = True + @classmethod + def _after_postgeneration(cls, instance, create, results=None): + """ + Save the instance again after the post generation operations. Needed to save + the password which is set in a post generation method call. + + Skip the save when the object was ‘built’ and not ‘created’. See the Factory Boy + documentation for details on those build strategies. + + This method replaces the deprecated method from DjangoModelFactory which is + scheduled to be removed in the next major release (see factory_boy's changelog + entry for version 3.3.0). + """ + if create: + instance.save() + class StaffFactory(UserFactory): """