﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33346	"assertFormsetError() crashes on formset named ""form""."	OutOfFocus4	Baptiste Mispelon	"I started updating a project from Django 3 to Django 4. When I ran my unit tests after the update, one of them failed with an AttributeError.

The full stack trace is

{{{
Traceback (most recent call last):
  File ""/private/tmp/example/example/tests.py"", line 17, in test_formset
    self.assertFormsetError(
  File ""/private/tmp/example/.venv/lib/python3.9/site-packages/django/test/testcases.py"", line 565, in assertFormsetError
    if field in context[formset].forms[form_index].errors:
AttributeError: 'ManagementForm' object has no attribute 'forms'
}}}

It looks like rendering the ManagementForm of a formset adds a context to response.context which contains a ""form"". Calling ""assertFormsetError"" to check for errors in a formset called ""form"" will check the formset's errors, but will also try to look at the errors in any ""form"" in all contexts, including the ManagementForm.
"	Bug	closed	Testing framework	4.0	Release blocker	fixed		David Smith Baptiste Mispelon	Ready for checkin	1	0	0	0	0	0
