-
Notifications
You must be signed in to change notification settings - Fork 410
Open
Description
Description
I am not sure if this is me using factory_boy wrong, or a bug. When i use a factory.SelfAttribute to pass a attribue to a provider it is evaluated if i pass it directly, but not if passed in a list (alone or with more factory.SelfAttribute's)
Model / Factory code
# Money object generated: ¥2,748
subtotal = factory.Faker("djmoney", currency=_currency)
# money is Money object: ¥2,748 / <class 'djmoney.money.Money'>
tax = factory.Faker(
"djmoney",
money=factory.SelfAttribute("..subtotal"),
multiplier=0.25,
)
# Money is not list of Money objects as expected:
# [<SelfAttribute('subtotal', default=<class 'factory.declarations._UNSPECIFIED'>)>]
# Also, the SelfAttribute says "subtotal" not "..subtotal" anymore?
total = factory.Faker(
"djmoney",
money=[
factory.SelfAttribute("..subtotal"),
# factory.SelfAttribute("..tax"), # Same problem with one or more list items
],
)Notes
I think the custom provider i am using is irellevant, but its code can be found here: https://gitlab.com/Kagee/homelab-organizer/-/blob/develop/hlo/factories/providers/moneyprovider.py
Metadata
Metadata
Assignees
Labels
No labels