-
Notifications
You must be signed in to change notification settings - Fork 42
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
Parametrized traits are not called from fixture in overriden Factory #98
Comments
Here's the repository: https://github.com/TauPan/pytest-factoryboy-reproduce-98 If I run the tests with Here are the travis results (currently still in progress): https://travis-ci.com/github/TauPan/pytest-factoryboy-reproduce-98
|
An alternative way to reproduce the same behaviour is: modified django_project/factories.py
@@ -1,24 +1,27 @@
from django_project import models
+import factory
import factory.django
class ThingFactory(factory.django.DjangoModelFactory):
- do_calculate = False
+ class Params:
+ do_calculate = False
class Meta:
model = models.Thing
- class Params:
- do_calculate = factory.Trait(
- _bogus=factory.PostGenerationMethodCall('calculate_sum')
- )
+ _set_sum = factory.Maybe(
+ 'do_calculate',
+ factory.PostGenerationMethodCall('calculate_sum')
+ )
class DoCalculateFactory(ThingFactory):
- do_calculate = True
+ class Params:
+ do_calculate = True
class Thing3Plus4Factory(DoCalculateFactory):
|
I forgot to mention:
This one indicates that not only the trait is not called, the parameters a and b are also not specialized by this: register(
factories.ThingFactory, 'thing3_plus4_arg', do_calculate=True, a=3, b=4) |
The general way to reproduce this is:
factory.django.DjangoModelFactory
factory.PostGenerationMethodCall
If I use the factory in a test, the method will not be called.
If I make a pytest fixture manually, calling the overridden factory directly, the method is called.
Since it's an involved case, I'll try to come up with a minimal example to reproduce this on github and reference this issue.
The text was updated successfully, but these errors were encountered: