Exemplo n.º 1
0
 def test_str_nested(self):
     compare(
         str(
             required(convert(source['foo'].y,
                              int)).insert(0).append().merge()),
         expected=
         ("required(convert(source['foo'].y, int)).insert(0).append().merge()"
          ))
Exemplo n.º 2
0
 def test_str_nested(self):
     compare(str(
         required(convert(source['foo'].y, int)).insert(0).append().merge()
     ), expected=(
         "required(convert(source['foo'].y, int)).insert(0).append().merge()"
     ))
Exemplo n.º 3
0
 def test_string_item_not_present_required(self):
     data = {}
     with ShouldRaise(NotPresent('foo')):
         load(data, required('foo'))
Exemplo n.º 4
0
 def test_attr_nested_not_present(self):
     data = Namespace()
     with ShouldRaise(NotPresent('x')):
        load(data, required(source.x.y))
Exemplo n.º 5
0
 def test_index_not_present(self):
     data = ['a']
     with ShouldRaise(NotPresent(1)):
         load(data, required(source[1]))
Exemplo n.º 6
0
 def test_getitem_nested_not_present(self):
     data = {}
     with ShouldRaise(NotPresent('foo')):
         load(data, required(source['foo']['bar']))
Exemplo n.º 7
0
 def test_ensure_on_required(self):
     data = '1'
     with ShouldRaise(TypeError('Cannot use required() as target')):
         store(data, required(target).x, 'y')
Exemplo n.º 8
0
 def test_required_and_present(self):
     data = ['a', 'b']
     compare(load(data, required(source[1])), expected='b')
Exemplo n.º 9
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.º 10
0
 def test_string_item_not_present_required(self):
     data = {}
     with ShouldRaise(NotPresent('foo')):
         load(data, required('foo'))
Exemplo n.º 11
0
 def test_attr_nested_not_present(self):
     data = Namespace()
     with ShouldRaise(NotPresent('x')):
         load(data, required(source.x.y))
Exemplo n.º 12
0
 def test_index_not_present(self):
     data = ['a']
     with ShouldRaise(NotPresent(1)):
         load(data, required(source[1]))
Exemplo n.º 13
0
 def test_getitem_nested_not_present(self):
     data = {}
     with ShouldRaise(NotPresent('foo')):
         load(data, required(source['foo']['bar']))
Exemplo n.º 14
0
 def test_ensure_on_required(self):
     data = '1'
     with ShouldRaise(TypeError('Cannot use required() as target')):
         store(data, required(target).x, 'y')
Exemplo n.º 15
0
 def test_required_and_present(self):
     data = ['a', 'b']
     compare(load(data, required(source[1])), expected='b')
Exemplo n.º 16
0
 def test_if_supplied_required_falsy(self):
     data = Namespace(x=None)
     with ShouldRaise(NotPresent(None)):
         load(data, required(if_supplied(source.x)))