You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Django and have a Model with multiple ForeginKey pointing to the same Model. I have factories created like:
class FooFactory(DjangoModelFactory):
class Meta:
model = Foo
value = factory.fuzzy.FuzzyInteger(100)
active = False
class BarFactory(DjangoModelFactory):
class Meta:
model = Bar
a = factory.SubFactory(FooFactory, active=True)
b = factory.SubFactory(FooFactory, active=False)
c = factory.SubFactory(FooFactory)
register(FooFactory, "foo")
register(BarFactory, "bar")
When I call BarFactory in test it creates object having different objects having different values. But when i get it by fixture it returns all fields having the same model attached ignoring additional flags.
So far I have made a workaround assigning a, b and c in BarFactory _create() method, but in that way i loose all benefits of this plugin.
The text was updated successfully, but these errors were encountered:
I guess I have kinda similar problem.
I have a factory with Subfactory:
class SupplierStatusFactory(factory.DjangoModelFactory):
name = factory.Faker('word')
code = factory.Sequence(lambda n: f'status_{n}')
class Meta:
model = SupplierStatus
class SupplierFactory(factory.DjangoModelFactory):
class Meta:
model = Supplier
...
status = factory.SubFactory(SupplierStatusFactory)
When I create objects calling SupplierFactory directly it creates 2 different SupplierStatus objects.
But when I use fixtures like this:
I'm using Django and have a Model with multiple ForeginKey pointing to the same Model. I have factories created like:
When I call BarFactory in test it creates object having different objects having different values. But when i get it by fixture it returns all fields having the same model attached ignoring additional flags.
So far I have made a workaround assigning a, b and c in BarFactory _create() method, but in that way i loose all benefits of this plugin.
The text was updated successfully, but these errors were encountered: