summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-07-19 13:55:32 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-07-23 20:12:08 +0200
commitd89053585e11e869efcc9debb1c311b47b5e20ea (patch)
tree94c606567d2611fb47914a59800af3d9ab2da6be /tests/forms_tests
parent8323691de0ba120dbdc8055063574df2b0c0afa4 (diff)
Improved error message when index in __getitem__() is invalid.
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_forms.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 18fb4a94de..45f5405fee 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -746,6 +746,15 @@ Java</label></li>
[str(bf[1]), str(bf[2]), str(bf[3])],
)
+ def test_boundfield_invalid_index(self):
+ class TestForm(Form):
+ name = ChoiceField(choices=[])
+
+ field = TestForm()['name']
+ msg = 'BoundField indices must be integers or slices, not str.'
+ with self.assertRaisesMessage(TypeError, msg):
+ field['foo']
+
def test_boundfield_bool(self):
"""BoundField without any choices (subwidgets) evaluates to True."""
class TestForm(Form):