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
This leads to an error when trying to write a strategy for a class that has a field named model. For example:
fromdjango.db.modelsimportModel, CharFieldclassCar(Model):
model=CharField(help_text="The model of the car.")
car_strategy=from_model(Car, model='Mustang')
This will result in the following error:
TypeError: from_model() got multiple values for argument 'model'
Perhaps the first argument to from_model could be named _model or _hypothesis_model or something like that?
The text was updated successfully, but these errors were encountered:
Ah, we had the same problem with builds() (#1106), which was fixed by manual validation of *args - it's inelegant, but fixes the problem.
In Python 3.8 (or later), we can instead use a named positional-only argument... but that's years away. Until then we can patch the __signature__ to fix our docs, like #2345, and get better introspection on new Pythons for free.
from_model's first argument ismodel:hypothesis/hypothesis-python/src/hypothesis/extra/django/_impl.py
Lines 57 to 59 in d159096
This leads to an error when trying to write a strategy for a class that has a field named
model. For example:This will result in the following error:
Perhaps the first argument to
from_modelcould be named_modelor_hypothesis_modelor something like that?The text was updated successfully, but these errors were encountered: