Skip to content

Commit

Permalink
Retire les usages d'une méthode obsolète de Factory Boy
Browse files Browse the repository at this point in the history
* remplace _after_postgeneration par une méthode custom
* conserve le comportement important pour notre code
* anticipe le prochain changement de version majeur
* facilite la lecture des logs d'obsolescence en évitant plus de 10,000 lignes liées à cette méthode
  • Loading branch information
Arnaud-D committed Oct 12, 2023
1 parent 7329dd3 commit 288bd7e
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 288bd7e

Please sign in to comment.