Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retire les usages d'une méthode obsolète de Factory Boy #6541

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions zds/member/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down