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
Because pytest-factoryboy replaces SubFactory with registered factories, it is possible to inadvertently create circular dependencies, which are not detected by pytest.
In my case, the setup was the following:
User factory
Company factory with a Contact subfactory.
user fixture overridden in the test file, depending on the company fixture
contact fixture overridden in the same file, depending on the company fixture.
Normally it should be fine because user -> company and contact -> company - there's no cycle. But, because the plugin creates a dependency company -> contact, the graph becomes: user -> company -> contact -> company and there's a cycle. Yet this cycle is a bit magical - I did not ask for company.contact and contact.company to be the same... I want a new, unrelated contact to be created for each company.
Would it be possible to add an option to disable this for those who don't need it? Or only some whitelisted subfactories? In my case, I would like the company.contact factory to be unrelated to the contact factory.
The text was updated successfully, but these errors were encountered:
Because
pytest-factoryboy
replacesSubFactory
with registered factories, it is possible to inadvertently create circular dependencies, which are not detected by pytest.In my case, the setup was the following:
User
factoryCompany
factory with aContact
subfactory.user
fixture overridden in the test file, depending on thecompany
fixturecontact
fixture overridden in the same file, depending on thecompany
fixture.Normally it should be fine because
user -> company
andcontact -> company
- there's no cycle. But, because the plugin creates a dependencycompany -> contact
, the graph becomes:user -> company -> contact -> company
and there's a cycle. Yet this cycle is a bit magical - I did not ask forcompany.contact
andcontact.company
to be the same... I want a new, unrelated contact to be created for each company.Would it be possible to add an option to disable this for those who don't need it? Or only some whitelisted subfactories? In my case, I would like the
company.contact
factory to be unrelated to thecontact
factory.The text was updated successfully, but these errors were encountered: