Exemplo n.º 1
0
 def test_index_not_present_okay(self):
     data = ['a']
     compare(load(data, source[1]), expected=NotPresent(1))
Exemplo n.º 2
0
 def test_attr_not_present_okay(self):
     data = Namespace()
     compare(load(data, source.x), expected=NotPresent('x'))
Exemplo n.º 3
0
 def test_attr_nested_not_present(self):
     data = Namespace()
     with ShouldRaise(NotPresent('x')):
         load(data, required(source.x.y))
Exemplo n.º 4
0
 def test_getitem_not_present_okay(self):
     data = {}
     compare(load(data, source['foo']), expected=NotPresent('foo'))
Exemplo n.º 5
0
 def test_if_supplied_falsy(self):
     data = Namespace(x=None)
     compare(load(data, if_supplied(source.x)), expected=NotPresent(None))
Exemplo n.º 6
0
 def test_index_not_present(self):
     data = ['a']
     with ShouldRaise(NotPresent(1)):
         load(data, required(source[1]))
Exemplo n.º 7
0
 def test_attr_not_present(self):
     data = Namespace(x=1)
     store(data, target.x, NotPresent('foo'))
     compare(data.x, 1)
Exemplo n.º 8
0
 def test_string_attr_not_present(self):
     data = Namespace()
     compare(load(data, 'foo'), expected=NotPresent('foo'))
Exemplo n.º 9
0
 def test_append_not_present(self):
     data = []
     store(data, target.append()['a'], NotPresent('foo'))
     compare(data, expected=[{}])
Exemplo n.º 10
0
 def test_insert_not_present(self):
     data = []
     store(data, target.insert(0)['a'], NotPresent('foo'))
     compare(data, expected=[{}])
Exemplo n.º 11
0
 def test_index_not_present(self):
     data = ['a', 'b']
     store(data, target[1], NotPresent(1))
     compare(data, expected=['a', 'b'])
Exemplo n.º 12
0
 def test_getitem_not_present(self):
     data = {'foo': 'bar'}
     store(data, target['foo'], NotPresent('foo'))
     compare(data, expected={'foo': 'bar'})
Exemplo n.º 13
0
 def test_if_supplied_required_falsy(self):
     data = Namespace(x=None)
     with ShouldRaise(NotPresent(None)):
         load(data, required(if_supplied(source.x)))
Exemplo n.º 14
0
 def test_nested_missing_okay(self):
     data = {'foo': []}
     compare(load(data, source['foo'][2].x), expected=NotPresent(2))
Exemplo n.º 15
0
 def test_merge_not_present(self):
     data = {'x': {'y': 2}}
     store(data, target['x'].merge(), NotPresent('foo'), MergeContext())
     compare(data, expected={'x': {'y': 2}})
Exemplo n.º 16
0
 def test_string_item_not_present(self):
     data = {}
     compare(load(data, 'foo'), expected=NotPresent('foo'))
Exemplo n.º 17
0
 def test_getitem_nested_not_present(self):
     data = {}
     with ShouldRaise(NotPresent('foo')):
         load(data, required(source['foo']['bar']))
Exemplo n.º 18
0
 def test_string_item_not_present_required(self):
     data = {}
     with ShouldRaise(NotPresent('foo')):
         load(data, required('foo'))
Exemplo n.º 19
0
 def test_convert_not_present(self):
     data = {}
     compare(load(data, convert('x', int)), expected=NotPresent('x'))