factory_boy icon indicating copy to clipboard operation
factory_boy copied to clipboard

Add failing test for traits chaining along with RelatedFactory and SubFactory

Open jrobichaud opened this issue 1 year ago • 2 comments

I found this bug and I made a PR to add a failing test.

According to the doc we should be allowed to chain Traits.

However when chaining traits we cannot have a reference to a SubFactory of a RelatedFactory.

The error I get is:

factory.errors.InvalidDeclarationError: Received deep context for unknown fields: {'nested__two': Maybe(<SelfAttribute('with_related_nested_override', default=False)>, yes=2, no=<factory.declarations.Skip object at 0x103bcd040>)} (known=[])

jrobichaud avatar Mar 11 '24 18:03 jrobichaud

Sweet, thanks for taking the time to submit this report with an example to reproduce! :star: It definitely increases the chances of someone picking this up, and clarifies the issue.

The fix might also solve #533, or #542.

francoisfreitag avatar Mar 13 '24 15:03 francoisfreitag

This suggested solution of #542 does not fix the problem and results in an additional failing test.

jrobichaud avatar Mar 13 '24 16:03 jrobichaud