summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2022-02-15 10:28:26 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-15 10:30:20 +0100
commitf7e0bffa2e9c8820c008e742f76b71feaf7dd89f (patch)
tree1acb52c7e2b0be1c0db7fec02ce838b8b0c0abeb /tests
parentd4c9dab74bc29c240c33879a1167e5fd0971c7bc (diff)
Refs #33348 -- Made SimpleTestCase.assertFormError() raise ValueError when "field" is passed without "form_index".
Diffstat (limited to 'tests')
-rw-r--r--tests/test_utils/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 92778439ed..f62a473357 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1603,6 +1603,17 @@ class AssertFormsetErrorTests(SimpleTestCase):
)
self.assertFormsetError(response, "formset", None, None, "error")
+ def test_non_form_errors_with_field(self):
+ response = mock.Mock(
+ context=[
+ {},
+ {"formset": TestFormset.invalid(nonform=True)},
+ ]
+ )
+ msg = "You must use field=None with form_index=None."
+ with self.assertRaisesMessage(ValueError, msg):
+ self.assertFormsetError(response, "formset", None, "field", "error")
+
def test_form_index_too_big(self):
msg = (
"The formset <TestFormset: bound=True valid=False total_forms=1> only has "