示例#1
0
 def test_getall_default_value_for_missing_key(self):
     d = ice.MultiDict()
     self.assertEqual(d.getall('a', 'foo'), 'foo')
示例#2
0
 def test_getall_for_multiple_value(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     d['a'] = 'bar'
     self.assertEqual(d.getall('a'), ['foo', 'bar'])
示例#3
0
 def test_getall_for_missing_key(self):
     d = ice.MultiDict()
     self.assertEqual(d.getall('a'), [])
示例#4
0
 def test_missing_key(self):
     d = ice.MultiDict()
     with self.assertRaises(KeyError) as cm:
         d['foo']
     self.assertEqual(str(cm.exception), "'foo'")
示例#5
0
 def test_getall_for_single_value(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     self.assertEqual(d.getall('a'), ['foo'])
示例#6
0
 def test_len(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     d['b'] = 'bar'
     d['b'] = 'baz'
     self.assertEqual(len(d), 2)
示例#7
0
 def test_getitem_for_multiple_values(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     d['a'] = 'bar'
     self.assertEqual(d['a'], 'bar')
示例#8
0
 def test_get(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     self.assertEqual(d.get('a'), 'foo')
     self.assertEqual(d.get('b', 'bar'), 'bar')
示例#9
0
 def test_getitem(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     self.assertEqual(d['a'], 'foo')
示例#10
0
 def test_setitem(self):
     d = ice.MultiDict()
     d['a'] = 'foo'
     d['b'] = 'bar'
     d['b'] = 'baz'
     self.assertEqual(d.data, {'a': ['foo'], 'b': ['bar', 'baz']})