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
We're using model-bakery for our testing, and in relation with recipes we stumbled onto an inconsistency in the library. While gen_from_choices returns a callable that is then generates the random value when being called by baker.make_recipe, for example gen_string (and the others) directly return the random value.
Expected behavior
With the example Recipe as written here, I would expect one of the two behaviours:
We're using model-bakery for our testing, and in relation with recipes we stumbled onto an inconsistency in the library. While
gen_from_choices
returns a callable that is then generates the random value when being called bybaker.make_recipe
, for examplegen_string
(and the others) directly return the random value.Expected behavior
With the example Recipe as written here, I would expect one of the two behaviours:
everything returns a callable
and each time I create a model instance with this recipe I get different values for
first_name
orlast_name
and alsouser_type
.everything returns a value
If I know everything returns a value, I would need to define the recipe in this way to achieve my goal of random values per creation:
functools.partial
also works.Actual behavior
With this recipe, what actually happens is:
first_name
andlast_name
always have the same (random) value, since they are called on module-loaduser_type
has a random value generated per instanceReproduction Steps
use the examples, add the imports, and use
baker.make_recipe
Versions
Python: 3.6 / 3.7
Django: 2.2.8
Model Bakery: 1.0.2
The text was updated successfully, but these errors were encountered: