From 059c9ab24c41e1460fd8b7af65ea8d5f80f1aa82 Mon Sep 17 00:00:00 2001 From: Sergey Parkhomenko Date: Thu, 11 Dec 2014 00:25:05 +0200 Subject: Fixed #23977 -- Added setdefault() method to HttpResponse --- tests/responses/tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/responses/tests.py b/tests/responses/tests.py index 9642790b9a..892c09b857 100644 --- a/tests/responses/tests.py +++ b/tests/responses/tests.py @@ -33,6 +33,20 @@ class HttpResponseBaseTests(SimpleTestCase): with self.assertRaisesMessage(IOError, 'This HttpResponseBase instance cannot tell its position'): r.tell() + def test_setdefault(self): + """ + HttpResponseBase.setdefault() should not change an existing header + and should be case insensitive. + """ + r = HttpResponseBase() + + r['Header'] = 'Value' + r.setdefault('header', 'changed') + self.assertEqual(r['header'], 'Value') + + r.setdefault('x-header', 'DefaultValue') + self.assertEqual(r['X-Header'], 'DefaultValue') + class HttpResponseTests(SimpleTestCase): def test_status_code(self): -- cgit v1.3