2012-06-08 00:08:47 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2010-05-29 00:39:52 +08:00
|
|
|
import copy
|
2010-05-29 00:27:09 +08:00
|
|
|
import pickle
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2011-02-13 10:24:05 +08:00
|
|
|
from django.http import (QueryDict, HttpResponse, SimpleCookie, BadHeaderError,
|
|
|
|
parse_cookie)
|
2010-10-11 20:55:17 +08:00
|
|
|
from django.utils import unittest
|
2010-05-29 00:27:09 +08:00
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
class QueryDictTests(unittest.TestCase):
|
|
|
|
def test_missing_key(self):
|
|
|
|
q = QueryDict('')
|
|
|
|
self.assertRaises(KeyError, q.__getitem__, 'foo')
|
|
|
|
|
|
|
|
def test_immutability(self):
|
|
|
|
q = QueryDict('')
|
|
|
|
self.assertRaises(AttributeError, q.__setitem__, 'something', 'bar')
|
|
|
|
self.assertRaises(AttributeError, q.setlist, 'foo', ['bar'])
|
|
|
|
self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar'])
|
|
|
|
self.assertRaises(AttributeError, q.update, {'foo': 'bar'})
|
|
|
|
self.assertRaises(AttributeError, q.pop, 'foo')
|
|
|
|
self.assertRaises(AttributeError, q.popitem)
|
|
|
|
self.assertRaises(AttributeError, q.clear)
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
def test_immutable_get_with_default(self):
|
|
|
|
q = QueryDict('')
|
|
|
|
self.assertEqual(q.get('foo', 'default'), 'default')
|
|
|
|
|
|
|
|
def test_immutable_basic_operations(self):
|
|
|
|
q = QueryDict('')
|
|
|
|
self.assertEqual(q.getlist('foo'), [])
|
|
|
|
self.assertEqual(q.has_key('foo'), False)
|
|
|
|
self.assertEqual('foo' in q, False)
|
|
|
|
self.assertEqual(q.items(), [])
|
|
|
|
self.assertEqual(q.lists(), [])
|
|
|
|
self.assertEqual(q.items(), [])
|
|
|
|
self.assertEqual(q.keys(), [])
|
|
|
|
self.assertEqual(q.values(), [])
|
|
|
|
self.assertEqual(len(q), 0)
|
|
|
|
self.assertEqual(q.urlencode(), '')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
def test_single_key_value(self):
|
|
|
|
"""Test QueryDict with one key/value pair"""
|
|
|
|
|
|
|
|
q = QueryDict('foo=bar')
|
|
|
|
self.assertEqual(q['foo'], 'bar')
|
|
|
|
self.assertRaises(KeyError, q.__getitem__, 'bar')
|
|
|
|
self.assertRaises(AttributeError, q.__setitem__, 'something', 'bar')
|
|
|
|
|
|
|
|
self.assertEqual(q.get('foo', 'default'), 'bar')
|
|
|
|
self.assertEqual(q.get('bar', 'default'), 'default')
|
|
|
|
self.assertEqual(q.getlist('foo'), ['bar'])
|
|
|
|
self.assertEqual(q.getlist('bar'), [])
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertRaises(AttributeError, q.setlist, 'foo', ['bar'])
|
|
|
|
self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar'])
|
|
|
|
|
2010-12-04 15:28:12 +08:00
|
|
|
self.assertTrue(q.has_key('foo'))
|
|
|
|
self.assertTrue('foo' in q)
|
|
|
|
self.assertFalse(q.has_key('bar'))
|
|
|
|
self.assertFalse('bar' in q)
|
2010-05-29 00:27:09 +08:00
|
|
|
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.items(), [('foo', 'bar')])
|
|
|
|
self.assertEqual(q.lists(), [('foo', ['bar'])])
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(q.keys(), ['foo'])
|
|
|
|
self.assertEqual(q.values(), ['bar'])
|
|
|
|
self.assertEqual(len(q), 1)
|
|
|
|
|
|
|
|
self.assertRaises(AttributeError, q.update, {'foo': 'bar'})
|
|
|
|
self.assertRaises(AttributeError, q.pop, 'foo')
|
|
|
|
self.assertRaises(AttributeError, q.popitem)
|
|
|
|
self.assertRaises(AttributeError, q.clear)
|
|
|
|
self.assertRaises(AttributeError, q.setdefault, 'foo', 'bar')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(q.urlencode(), 'foo=bar')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-12-02 06:25:17 +08:00
|
|
|
def test_urlencode(self):
|
|
|
|
q = QueryDict('', mutable=True)
|
|
|
|
q['next'] = '/a&b/'
|
|
|
|
self.assertEqual(q.urlencode(), 'next=%2Fa%26b%2F')
|
|
|
|
self.assertEqual(q.urlencode(safe='/'), 'next=/a%26b/')
|
|
|
|
q = QueryDict('', mutable=True)
|
2012-06-08 00:08:47 +08:00
|
|
|
q['next'] = '/t\xebst&key/'
|
2010-12-02 06:25:17 +08:00
|
|
|
self.assertEqual(q.urlencode(), 'next=%2Ft%C3%ABst%26key%2F')
|
|
|
|
self.assertEqual(q.urlencode(safe='/'), 'next=/t%C3%ABst%26key/')
|
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
def test_mutable_copy(self):
|
|
|
|
"""A copy of a QueryDict is mutable."""
|
|
|
|
q = QueryDict('').copy()
|
|
|
|
self.assertRaises(KeyError, q.__getitem__, "foo")
|
|
|
|
q['name'] = 'john'
|
|
|
|
self.assertEqual(q['name'], 'john')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
def test_mutable_delete(self):
|
|
|
|
q = QueryDict('').copy()
|
|
|
|
q['name'] = 'john'
|
|
|
|
del q['name']
|
2010-12-04 15:28:12 +08:00
|
|
|
self.assertFalse('name' in q)
|
2010-05-29 00:27:09 +08:00
|
|
|
|
|
|
|
def test_basic_mutable_operations(self):
|
|
|
|
q = QueryDict('').copy()
|
|
|
|
q['name'] = 'john'
|
|
|
|
self.assertEqual(q.get('foo', 'default'), 'default')
|
|
|
|
self.assertEqual(q.get('name', 'default'), 'john')
|
|
|
|
self.assertEqual(q.getlist('name'), ['john'])
|
|
|
|
self.assertEqual(q.getlist('foo'), [])
|
|
|
|
|
|
|
|
q.setlist('foo', ['bar', 'baz'])
|
|
|
|
self.assertEqual(q.get('foo', 'default'), 'baz')
|
|
|
|
self.assertEqual(q.getlist('foo'), ['bar', 'baz'])
|
|
|
|
|
|
|
|
q.appendlist('foo', 'another')
|
|
|
|
self.assertEqual(q.getlist('foo'), ['bar', 'baz', 'another'])
|
|
|
|
self.assertEqual(q['foo'], 'another')
|
2010-12-04 15:28:12 +08:00
|
|
|
self.assertTrue(q.has_key('foo'))
|
|
|
|
self.assertTrue('foo' in q)
|
2010-05-29 00:27:09 +08:00
|
|
|
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.items(), [('foo', 'another'), ('name', 'john')])
|
|
|
|
self.assertEqual(q.lists(), [('foo', ['bar', 'baz', 'another']), ('name', ['john'])])
|
|
|
|
self.assertEqual(q.keys(), ['foo', 'name'])
|
|
|
|
self.assertEqual(q.values(), ['another', 'john'])
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(len(q), 2)
|
|
|
|
|
|
|
|
q.update({'foo': 'hello'})
|
|
|
|
self.assertEqual(q['foo'], 'hello')
|
|
|
|
self.assertEqual(q.get('foo', 'not available'), 'hello')
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.getlist('foo'), ['bar', 'baz', 'another', 'hello'])
|
|
|
|
self.assertEqual(q.pop('foo'), ['bar', 'baz', 'another', 'hello'])
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(q.pop('foo', 'not there'), 'not there')
|
|
|
|
self.assertEqual(q.get('foo', 'not there'), 'not there')
|
|
|
|
self.assertEqual(q.setdefault('foo', 'bar'), 'bar')
|
|
|
|
self.assertEqual(q['foo'], 'bar')
|
|
|
|
self.assertEqual(q.getlist('foo'), ['bar'])
|
|
|
|
self.assertEqual(q.urlencode(), 'foo=bar&name=john')
|
|
|
|
|
|
|
|
q.clear()
|
|
|
|
self.assertEqual(len(q), 0)
|
|
|
|
|
|
|
|
def test_multiple_keys(self):
|
|
|
|
"""Test QueryDict with two key/value pairs with same keys."""
|
|
|
|
|
|
|
|
q = QueryDict('vote=yes&vote=no')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q['vote'], 'no')
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertRaises(AttributeError, q.__setitem__, 'something', 'bar')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.get('vote', 'default'), 'no')
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(q.get('foo', 'default'), 'default')
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.getlist('vote'), ['yes', 'no'])
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(q.getlist('foo'), [])
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertRaises(AttributeError, q.setlist, 'foo', ['bar', 'baz'])
|
|
|
|
self.assertRaises(AttributeError, q.setlist, 'foo', ['bar', 'baz'])
|
|
|
|
self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar'])
|
|
|
|
|
2010-10-11 20:55:17 +08:00
|
|
|
self.assertEqual(q.has_key('vote'), True)
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual('vote' in q, True)
|
|
|
|
self.assertEqual(q.has_key('foo'), False)
|
|
|
|
self.assertEqual('foo' in q, False)
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.items(), [('vote', 'no')])
|
|
|
|
self.assertEqual(q.lists(), [('vote', ['yes', 'no'])])
|
|
|
|
self.assertEqual(q.keys(), ['vote'])
|
|
|
|
self.assertEqual(q.values(), ['no'])
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertEqual(len(q), 1)
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
self.assertRaises(AttributeError, q.update, {'foo': 'bar'})
|
|
|
|
self.assertRaises(AttributeError, q.pop, 'foo')
|
|
|
|
self.assertRaises(AttributeError, q.popitem)
|
|
|
|
self.assertRaises(AttributeError, q.clear)
|
|
|
|
self.assertRaises(AttributeError, q.setdefault, 'foo', 'bar')
|
|
|
|
self.assertRaises(AttributeError, q.__delitem__, 'vote')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
def test_invalid_input_encoding(self):
|
|
|
|
"""
|
|
|
|
QueryDicts must be able to handle invalid input encoding (in this
|
|
|
|
case, bad UTF-8 encoding).
|
|
|
|
"""
|
2012-05-19 23:43:34 +08:00
|
|
|
q = QueryDict(b'foo=bar&foo=\xff')
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q['foo'], '\ufffd')
|
|
|
|
self.assertEqual(q.getlist('foo'), ['bar', '\ufffd'])
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
def test_pickle(self):
|
|
|
|
q = QueryDict('')
|
|
|
|
q1 = pickle.loads(pickle.dumps(q, 2))
|
|
|
|
self.assertEqual(q == q1, True)
|
|
|
|
q = QueryDict('a=b&c=d')
|
|
|
|
q1 = pickle.loads(pickle.dumps(q, 2))
|
|
|
|
self.assertEqual(q == q1, True)
|
2010-10-11 20:55:17 +08:00
|
|
|
q = QueryDict('a=b&c=d&a=1')
|
2010-05-29 00:27:09 +08:00
|
|
|
q1 = pickle.loads(pickle.dumps(q, 2))
|
2012-07-15 05:07:11 +08:00
|
|
|
self.assertEqual(q == q1, True)
|
2010-05-29 00:27:09 +08:00
|
|
|
|
|
|
|
def test_update_from_querydict(self):
|
|
|
|
"""Regression test for #8278: QueryDict.update(QueryDict)"""
|
|
|
|
x = QueryDict("a=1&a=2", mutable=True)
|
|
|
|
y = QueryDict("a=3&a=4")
|
|
|
|
x.update(y)
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(x.getlist('a'), ['1', '2', '3', '4'])
|
2010-05-29 00:27:09 +08:00
|
|
|
|
2010-05-29 00:39:52 +08:00
|
|
|
def test_non_default_encoding(self):
|
|
|
|
"""#13572 - QueryDict with a non-default encoding"""
|
2012-05-19 23:43:34 +08:00
|
|
|
q = QueryDict(b'sbb=one', encoding='rot_13')
|
2010-05-29 00:39:52 +08:00
|
|
|
self.assertEqual(q.encoding , 'rot_13' )
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.items() , [('foo', 'bar')] )
|
2010-05-29 00:39:52 +08:00
|
|
|
self.assertEqual(q.urlencode() , 'sbb=one' )
|
2010-10-11 20:55:17 +08:00
|
|
|
q = q.copy()
|
2010-05-29 00:39:52 +08:00
|
|
|
self.assertEqual(q.encoding , 'rot_13' )
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertEqual(q.items() , [('foo', 'bar')] )
|
2010-05-29 00:39:52 +08:00
|
|
|
self.assertEqual(q.urlencode() , 'sbb=one' )
|
|
|
|
self.assertEqual(copy.copy(q).encoding , 'rot_13' )
|
|
|
|
self.assertEqual(copy.deepcopy(q).encoding , 'rot_13')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
class HttpResponseTests(unittest.TestCase):
|
|
|
|
def test_unicode_headers(self):
|
|
|
|
r = HttpResponse()
|
|
|
|
|
|
|
|
# If we insert a unicode value it will be converted to an ascii
|
2012-06-08 00:08:47 +08:00
|
|
|
r['value'] = 'test value'
|
2010-12-04 15:28:12 +08:00
|
|
|
self.assertTrue(isinstance(r['value'], str))
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2011-09-15 07:27:35 +08:00
|
|
|
# An error is raised when a unicode object with non-ascii is assigned.
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertRaises(UnicodeEncodeError, r.__setitem__, 'value', 't\xebst value')
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-09-11 09:41:53 +08:00
|
|
|
# An error is raised when a unicode object with non-ASCII format is
|
|
|
|
# passed as initial mimetype or content_type.
|
|
|
|
self.assertRaises(UnicodeEncodeError, HttpResponse,
|
2012-06-08 00:08:47 +08:00
|
|
|
content_type='t\xebst value')
|
2010-09-11 09:41:53 +08:00
|
|
|
|
|
|
|
# HttpResponse headers must be convertible to ASCII.
|
|
|
|
self.assertRaises(UnicodeEncodeError, HttpResponse,
|
2012-06-08 00:08:47 +08:00
|
|
|
content_type='t\xebst value')
|
2010-09-11 09:41:53 +08:00
|
|
|
|
2010-10-11 20:55:17 +08:00
|
|
|
# The response also converts unicode keys to strings.)
|
2012-06-08 00:08:47 +08:00
|
|
|
r['test'] = 'testing key'
|
2010-05-29 00:27:09 +08:00
|
|
|
l = list(r.items())
|
|
|
|
l.sort()
|
|
|
|
self.assertEqual(l[1], ('test', 'testing key'))
|
2010-10-11 20:55:17 +08:00
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
# It will also raise errors for keys with non-ascii data.
|
2012-06-08 00:08:47 +08:00
|
|
|
self.assertRaises(UnicodeEncodeError, r.__setitem__, 't\xebst key', 'value')
|
2010-05-29 00:27:09 +08:00
|
|
|
|
|
|
|
def test_newlines_in_headers(self):
|
|
|
|
# Bug #10188: Do not allow newlines in headers (CR or LF)
|
|
|
|
r = HttpResponse()
|
|
|
|
self.assertRaises(BadHeaderError, r.__setitem__, 'test\rstr', 'test')
|
|
|
|
self.assertRaises(BadHeaderError, r.__setitem__, 'test\nstr', 'test')
|
|
|
|
|
2011-06-17 00:34:46 +08:00
|
|
|
def test_dict_behavior(self):
|
|
|
|
"""
|
|
|
|
Test for bug #14020: Make HttpResponse.get work like dict.get
|
|
|
|
"""
|
|
|
|
r = HttpResponse()
|
|
|
|
self.assertEqual(r.get('test'), None)
|
|
|
|
|
2011-09-15 07:27:35 +08:00
|
|
|
def test_non_string_content(self):
|
|
|
|
#Bug 16494: HttpResponse should behave consistently with non-strings
|
|
|
|
r = HttpResponse(12345)
|
|
|
|
self.assertEqual(r.content, '12345')
|
|
|
|
|
|
|
|
#test content via property
|
|
|
|
r = HttpResponse()
|
|
|
|
r.content = 12345
|
|
|
|
self.assertEqual(r.content, '12345')
|
|
|
|
|
|
|
|
def test_iter_content(self):
|
|
|
|
r = HttpResponse(['abc', 'def', 'ghi'])
|
|
|
|
self.assertEqual(r.content, 'abcdefghi')
|
|
|
|
|
|
|
|
#test iter content via property
|
|
|
|
r = HttpResponse()
|
|
|
|
r.content = ['idan', 'alex', 'jacob']
|
|
|
|
self.assertEqual(r.content, 'idanalexjacob')
|
|
|
|
|
|
|
|
r = HttpResponse()
|
|
|
|
r.content = [1, 2, 3]
|
|
|
|
self.assertEqual(r.content, '123')
|
|
|
|
|
|
|
|
#test retrieval explicitly using iter and odd inputs
|
|
|
|
r = HttpResponse()
|
2012-06-08 00:08:47 +08:00
|
|
|
r.content = ['1', '2', 3, unichr(1950)]
|
2011-09-15 07:27:35 +08:00
|
|
|
result = []
|
|
|
|
my_iter = r.__iter__()
|
|
|
|
while True:
|
|
|
|
try:
|
2012-05-11 02:14:04 +08:00
|
|
|
result.append(next(my_iter))
|
2011-09-15 07:27:35 +08:00
|
|
|
except StopIteration:
|
|
|
|
break
|
|
|
|
#'\xde\x9e' == unichr(1950).encode('utf-8')
|
2012-05-19 23:43:34 +08:00
|
|
|
self.assertEqual(result, ['1', '2', '3', b'\xde\x9e'])
|
|
|
|
self.assertEqual(r.content, b'123\xde\x9e')
|
2011-09-15 07:27:35 +08:00
|
|
|
|
|
|
|
#with Content-Encoding header
|
|
|
|
r = HttpResponse([1,1,2,4,8])
|
|
|
|
r['Content-Encoding'] = 'winning'
|
|
|
|
self.assertEqual(r.content, '11248')
|
|
|
|
r.content = [unichr(1950),]
|
|
|
|
self.assertRaises(UnicodeEncodeError,
|
|
|
|
getattr, r, 'content')
|
|
|
|
|
2010-05-29 00:27:09 +08:00
|
|
|
class CookieTests(unittest.TestCase):
|
2010-01-24 07:13:00 +08:00
|
|
|
def test_encode(self):
|
|
|
|
"""
|
|
|
|
Test that we don't output tricky characters in encoded value
|
|
|
|
"""
|
2011-01-25 04:35:46 +08:00
|
|
|
c = SimpleCookie()
|
2010-01-24 07:13:00 +08:00
|
|
|
c['test'] = "An,awkward;value"
|
2011-03-03 23:04:39 +08:00
|
|
|
self.assertTrue(";" not in c.output().rstrip(';')) # IE compat
|
|
|
|
self.assertTrue("," not in c.output().rstrip(';')) # Safari compat
|
2010-01-24 07:13:00 +08:00
|
|
|
|
|
|
|
def test_decode(self):
|
|
|
|
"""
|
|
|
|
Test that we can still preserve semi-colons and commas
|
|
|
|
"""
|
2011-01-25 04:35:46 +08:00
|
|
|
c = SimpleCookie()
|
2010-01-24 07:13:00 +08:00
|
|
|
c['test'] = "An,awkward;value"
|
2011-01-25 04:35:46 +08:00
|
|
|
c2 = SimpleCookie()
|
2010-01-24 07:13:00 +08:00
|
|
|
c2.load(c.output())
|
|
|
|
self.assertEqual(c['test'].value, c2['test'].value)
|
|
|
|
|
|
|
|
def test_decode_2(self):
|
|
|
|
"""
|
|
|
|
Test that we haven't broken normal encoding
|
|
|
|
"""
|
2011-01-25 04:35:46 +08:00
|
|
|
c = SimpleCookie()
|
2012-05-19 23:43:34 +08:00
|
|
|
c['test'] = b"\xf0"
|
2011-01-25 04:35:46 +08:00
|
|
|
c2 = SimpleCookie()
|
2010-01-24 07:13:00 +08:00
|
|
|
c2.load(c.output())
|
|
|
|
self.assertEqual(c['test'].value, c2['test'].value)
|
2011-02-13 10:24:05 +08:00
|
|
|
|
|
|
|
def test_nonstandard_keys(self):
|
|
|
|
"""
|
|
|
|
Test that a single non-standard cookie name doesn't affect all cookies. Ticket #13007.
|
|
|
|
"""
|
|
|
|
self.assertTrue('good_cookie' in parse_cookie('good_cookie=yes;bad:cookie=yes').keys())
|
2011-06-26 00:18:40 +08:00
|
|
|
|
|
|
|
def test_repeated_nonstandard_keys(self):
|
|
|
|
"""
|
|
|
|
Test that a repeated non-standard name doesn't affect all cookies. Ticket #15852
|
|
|
|
"""
|
|
|
|
self.assertTrue('good_cookie' in parse_cookie('a,=b; a,=c; good_cookie=yes').keys())
|
2011-07-08 20:07:54 +08:00
|
|
|
|
|
|
|
def test_httponly_after_load(self):
|
|
|
|
"""
|
|
|
|
Test that we can use httponly attribute on cookies that we load
|
|
|
|
"""
|
|
|
|
c = SimpleCookie()
|
|
|
|
c.load("name=val")
|
|
|
|
c['name']['httponly'] = True
|
|
|
|
self.assertTrue(c['name']['httponly'])
|
|
|
|
|