示例#1
0
    def test_get_raises_type_error(self):
        with raises(TypeError):
            shackles.get(obj, 'e', 1, 2)

        with raises(TypeError):
            shackles.get(obj, 'e', default=1)
示例#2
0
 def test_get_default(self):
     assert shackles.get(obj, 'e', True) == True
示例#3
0
 def test_get_raises_attribute_error(self):
     with raises(AttributeError):
         shackles.get(obj, 'e')
示例#4
0
 def test_get_list(self):
     assert shackles.get(obj, ['a','b']).name == 'b'
     assert shackles.get(obj, ['a','b','name']) == 'b'
示例#5
0
 def test_get_tuple(self):
     assert shackles.get(obj, ('a','b')).name == 'b'
     assert shackles.get(obj, ('a','b','name')) == 'b'
示例#6
0
    def test_get_raises_type_error(self):
        with raises(TypeError):
            shackles.get(self.obj, 'e', 1, 2)

        with raises(TypeError):
            shackles.get(self.obj, 'e', default=1)
示例#7
0
 def test_get_str(self):
     assert shackles.get(obj, 'a.b').name == 'b'
     assert shackles.get(obj, 'a.b.name') == 'b'
示例#8
0
 def test_get_raises_attribute_error(self):
     with raises(AttributeError):
         shackles.get(self.obj, 'e')
示例#9
0
 def test_get_default(self):
     assert shackles.get(self.obj, 'e', True) == True
示例#10
0
 def test_get_tuple(self):
     assert shackles.get(self.obj, ('a', 'b')).name == 'b'
     assert shackles.get(self.obj, ('a', 'b', 'name')) == 'b'
示例#11
0
 def test_get_list(self):
     assert shackles.get(self.obj, ['a', 'b']).name == 'b'
     assert shackles.get(self.obj, ['a', 'b', 'name']) == 'b'
示例#12
0
 def test_get_str(self):
     assert shackles.get(self.obj, 'a.b').name == 'b'
     assert shackles.get(self.obj, 'a.b.name') == 'b'