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
Traceback (most recent call last):
File "test.py", line 29, in <module>
value = ThingFactory()
File "/usr/local/lib/python3.6/site-packages/factory/base.py", line 46, in __call__
return cls.create(**kwargs)
File "/usr/local/lib/python3.6/site-packages/factory/base.py", line 563, in create
return cls._generate(enums.CREATE_STRATEGY, kwargs)
File "/usr/local/lib/python3.6/site-packages/factory/base.py", line 500, in _generate
return step.build()
File "/usr/local/lib/python3.6/site-packages/factory/builder.py", line 288, in build
context=declaration.context,
File "/usr/local/lib/python3.6/site-packages/factory/declarations.py", line 41, in unroll_context
return step.recurse(subfactory, context, force_sequence=step.sequence)
File "/usr/local/lib/python3.6/site-packages/factory/builder.py", line 233, in recurse
return builder.build(parent_step=self, force_sequence=force_sequence)
File "/usr/local/lib/python3.6/site-packages/factory/builder.py", line 257, in build
base_post=self.factory_meta.post_declarations,
File "/usr/local/lib/python3.6/site-packages/factory/builder.py", line 198, in parse_declarations
for k, v in extra_maybenonpost.items()
File "/usr/local/lib/python3.6/site-packages/factory/builder.py", line 92, in update
sorted(self.declarations),
factory.errors.InvalidDeclarationError: Received deep context for unknown fields:
{'nested__count': Maybe(<SelfAttribute('with_nested', default=False)>, yes=1, no=<factory.declarations.Skip object at 0x1068cdf28>)}
(known=['count'])
It seems like the second param isn't being extracted properly. I don't understand the code well enough to diagnose exactly why this happens, so I won't put any half-baked theories in here.
The issue
I think this issue is a symptom of a deeper problem: there's no standard way to override the arguments passed to a post_generation hook. (I don't know if this is also the case for subfactories.)
Doing it in a Trait seems a little dirty, since (at least according to the docs) it's meant to override fields.
It seems like it could belong in _alter_kwargs(), but it that method doesn't actually alter the raw kwargs.
If it's meant to stay in a Trait, updating the docs to reflect that would be very helpful.
The text was updated successfully, but these errors were encountered:
same issue for me. after migration from 2.8.0 to 2.11.1 all traits seems broken. i widely used deep arguments in code to provide additional context in dependency of object status.
for example
class Params:
reported = Trait(
report_attachments__count=1,
report_attachments__file_type__name='report',
)
Does any way exists to refactor code without bloody mess?
Description
This seems to be a continuation of #466
It seems like defining a trait will let you pass kwargs, but only one level deep.
Here is an example:
To Reproduce
This (naturally) fails:
It seems like the second param isn't being extracted properly. I don't understand the code well enough to diagnose exactly why this happens, so I won't put any half-baked theories in here.
The issue
I think this issue is a symptom of a deeper problem: there's no standard way to override the arguments passed to a
post_generation
hook. (I don't know if this is also the case for subfactories.)Doing it in a
Trait
seems a little dirty, since (at least according to the docs) it's meant to override fields.It seems like it could belong in
_alter_kwargs()
, but it that method doesn't actually alter the rawkwargs
.If it's meant to stay in a Trait, updating the docs to reflect that would be very helpful.
The text was updated successfully, but these errors were encountered: