[Answered ]-Upgrade to Django 4.0 has caused tests to fail even when the feature being tested works

1👍

Answer is that in Django 4.1 assertFormError don’t get response in args
https://docs.djangoproject.com/en/4.1/releases/4.1/#id2

Passing a response object and a form/formset name to SimpleTestCase.assertFormError() and assertFormsetError() is deprecated. Use:

assertFormError(response.context['form_name'], …)
assertFormsetError(response.context['formset_name'], …)

your test will be correct:

self.assertFormError(response.context['form'], 'date', 'Date must be within current financial year')
👤Blayne

Leave a comment