Beispiel #1
0
 def test_two_keys__good__with_default(self):
     func = __unit__.key_func('foo', 'bar', default=self.DEFAULT)
     self.assertEquals(
         self.DOUBLY_NESTED_DICT['foo']['bar'],
         func(self.DOUBLY_NESTED_DICT))
Beispiel #2
0
 def test_two_keys__bad__with_default(self):
     func = __unit__.key_func('foo', 'doesnt_exist', default=self.DEFAULT)
     self.assertEquals(self.DEFAULT, func(self.DOUBLY_NESTED_DICT))
Beispiel #3
0
 def test_single_key__good__with_default(self):
     func = __unit__.key_func('foo', default=self.DEFAULT)
     self.assertEquals(
         self.SINGLY_NESTED_DICT['foo'], func(self.SINGLY_NESTED_DICT))
     self.assertEquals(
         self.DOUBLY_NESTED_DICT['foo'], func(self.DOUBLY_NESTED_DICT))
Beispiel #4
0
 def test_single_key__bad__with_default(self):
     func = __unit__.key_func('doesnt_exist', default=self.DEFAULT)
     self.assertEquals(self.DEFAULT, func(self.SINGLY_NESTED_DICT))
     self.assertEquals(self.DEFAULT, func(self.DOUBLY_NESTED_DICT))
Beispiel #5
0
 def test_two_keys__good(self):
     func = __unit__.key_func('foo', 'bar')
     self.assertEquals(
         self.DOUBLY_NESTED_DICT['foo']['bar'],
         func(self.DOUBLY_NESTED_DICT))
Beispiel #6
0
 def test_two_keys__bad(self):
     func = __unit__.key_func('doesnt_exist', 'foo')
     with self.assertRaises(LookupError):
         func(self.DOUBLY_NESTED_DICT)
Beispiel #7
0
 def test_single_key__bad(self):
     func = __unit__.key_func('doesnt_exist')
     with self.assertRaises(LookupError):
         func(self.SINGLY_NESTED_DICT)
     with self.assertRaises(LookupError):
         func(self.DOUBLY_NESTED_DICT)
Beispiel #8
0
 def test_single_key__good(self):
     func = __unit__.key_func('foo')
     self.assertEquals(
         self.SINGLY_NESTED_DICT['foo'], func(self.SINGLY_NESTED_DICT))
     self.assertEquals(
         self.DOUBLY_NESTED_DICT['foo'], func(self.DOUBLY_NESTED_DICT))
Beispiel #9
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.key_func(object())
Beispiel #10
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.key_func(None)
Beispiel #11
0
 def test_no_args(self):
     with self.assertRaises(TypeError):
         __unit__.key_func()