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