summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorTim Heap <tim@timheap.me>2014-11-21 12:35:58 +1100
committerClaude Paroz <claude@2xlibre.net>2014-11-21 09:45:08 +0100
commit5b17dcd8ef9c444af2e0a234d708c37b313ef04f (patch)
treeb5a6e312da51b88846e5f4301c282978dcb745df /tests/forms_tests
parentd8f00e1918ce4df76920f3d79bc8d805fa69e29e (diff)
downloaddjango-5b17dcd8ef9c444af2e0a234d708c37b313ef04f.tar.gz
Fixed #23883 -- Stopped flatatt modifying its argument
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_util.py b/tests/forms_tests/tests/test_util.py
index 68ecd50e99..c37affeb31 100644
--- a/tests/forms_tests/tests/test_util.py
+++ b/tests/forms_tests/tests/test_util.py
@@ -27,6 +27,23 @@ class FormsUtilTestCase(TestCase):
self.assertEqual(flatatt({'class': "news", 'title': "Read this", 'required': False}), ' class="news" title="Read this"')
self.assertEqual(flatatt({}), '')
+ def test_flatatt_no_side_effects(self):
+ """
+ Fixes #23883 -- Check that flatatt does not modify the dict passed in
+ """
+ attrs = {'foo': 'bar', 'true': True, 'false': False}
+ attrs_copy = copy.copy(attrs)
+ self.assertEqual(attrs, attrs_copy)
+
+ first_run = flatatt(attrs)
+ self.assertEqual(attrs, attrs_copy)
+ self.assertEqual(first_run, ' foo="bar" true')
+
+ second_run = flatatt(attrs)
+ self.assertEqual(attrs, attrs_copy)
+
+ self.assertEqual(first_run, second_run)
+
def test_validation_error(self):
###################
# ValidationError #