Open arjoonn-s opened 2 months ago
Hmm, unfortunately none of Hypothesis' regular contributors are Django users, so it's pretty plausible that we've missed an upstream change or something like that. I'd be happy to accept a patch, but would appreciate more-detailed-than-usual notes pointing to Django docs etc to explain what's going on 🙂
More than happy to help! Hypo has been of great use to us in testing our django codebase.
form = MyForm(data=request.POST, files=request.FILES)
refform.is_valid()
to check if the form is valid.The problem arises when we have FileField
in the form for handling file uploads.
data
, the content of the file never reaches the django form.The expected code would be to have the hypo code in the referred section as:
return _forms_impl(
st.builds(
partial(form, **form_kwargs), # type: ignore
data=st.fixed_dictionaries(non_file_field_strategies), # type: ignore
files=st.fixed_dictionaries(file_field_strategies), # type: ignore
)
)
thus passing the strategies correctly to the form builder.
Does that make more sense? I'm happy to answer any other questions.
Sounds great!
The from_form function does not bind files correctly.
From the source available I think it should be supplying file fields separately. Currently it is running:
I think it should have been something like:
cc @sethuvishal
Is this expected? If not I think we're happy to submit a patch for this.