diff --git a/envergo/evaluations/tests/factories.py b/envergo/evaluations/tests/factories.py index 59f4afc40..3a7b6a9c6 100644 --- a/envergo/evaluations/tests/factories.py +++ b/envergo/evaluations/tests/factories.py @@ -9,6 +9,7 @@ class EvaluationFactory(DjangoModelFactory): class Meta: model = Evaluation + skip_postgeneration_save = True application_number = factory.Sequence(lambda n: f"PC05112321D{n:04}") evaluation_file = factory.django.FileField(filename="eval.pdf", data=b"Hello") @@ -48,6 +49,7 @@ class Meta: class RequestFactory(DjangoModelFactory): class Meta: model = Request + skip_postgeneration_save = True reference = factory.Sequence(lambda n: f"ABC{n:03}") address = factory.Sequence(lambda n: f"{n} rue de l'example, Testville") diff --git a/envergo/users/tests/factories.py b/envergo/users/tests/factories.py index cc6b5e227..e025efa46 100644 --- a/envergo/users/tests/factories.py +++ b/envergo/users/tests/factories.py @@ -1,30 +1,12 @@ -from typing import Any, Sequence - from django.contrib.auth import get_user_model -from factory import Faker, post_generation -from factory.django import DjangoModelFactory +from factory import Faker +from factory.django import DjangoModelFactory, Password class UserFactory(DjangoModelFactory): - email = Faker("email") name = Faker("name") - - @post_generation - def password(self, create: bool, extracted: Sequence[Any], **kwargs): - password = ( - extracted - if extracted - else Faker( - "password", - length=42, - special_chars=True, - digits=True, - upper_case=True, - lower_case=True, - ).evaluate(None, None, extra={"locale": None}) - ) - self.set_password(password) + password = Password("password") class Meta: model = get_user_model()