Fixed #23977 -- Added setdefault() method to HttpResponse

This commit is contained in:
Sergey Parkhomenko 2014-12-11 00:25:05 +02:00 committed by Tim Graham
parent d4e449d730
commit 059c9ab24c
4 changed files with 29 additions and 0 deletions

View file

@ -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):