From 74e14541137d444b01fa947d7408f9d4a049ad9d Mon Sep 17 00:00:00 2001 From: Peter Andersen Date: Mon, 9 Dec 2019 08:54:40 -0800 Subject: [3.0.x] Fixed #31073 -- Prevented CheckboxInput.get_context() from mutating attrs. Backport of 02eff7ef60466da108b1a33f1e4dc01eec45c99d from master --- tests/postgres_tests/test_array.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/postgres_tests/test_array.py') diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index 42885e61f6..29b67d6fbc 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -1003,6 +1003,17 @@ class TestSplitFormWidget(PostgreSQLWidgetTestCase): } ) + def test_checkbox_get_context_attrs(self): + context = SplitArrayWidget( + forms.CheckboxInput(), + size=2, + ).get_context('name', [True, False]) + self.assertEqual(context['widget']['value'], '[True, False]') + self.assertEqual( + [subwidget['attrs'] for subwidget in context['widget']['subwidgets']], + [{'checked': True}, {}] + ) + def test_render(self): self.check_html( SplitArrayWidget(forms.TextInput(), size=2), 'array', None, -- cgit v1.3