Пример #1
0
 def test_any_of_json_codec(self):
     for value in [123.45, False]:
         schema = s.any_of([s.float(), s.bool()])
         self.assertEqual(schema.json_decode(schema.json_encode(value)),
                          value)
Пример #2
0
 def test_any_of_none_match(self):
     self._error(s.any_of([s.str(), s.int()]).validate, 123.45)
Пример #3
0
 def test_any_of_either_match(self):
     s.any_of([s.str(), s.int()]).validate("one")
     s.any_of([s.str(), s.int()]).validate(1)
Пример #4
0
def test_any_of_json_codec():
    for value in [123.45, False]:
        schema = s.any_of([s.float(), s.bool()])
        assert schema.json_decode(schema.json_encode(value)) == value
Пример #5
0
def test_any_of_match_str():
    assert isinstance(s.any_of((s.int(), s.str())).match("one"), s.str)
Пример #6
0
def test_any_of_match_int():
    assert isinstance(s.any_of((s.int(), s.str())).match(1), s.int)
Пример #7
0
def test_any_of_nullable_inner():
    s.any_of((s.int(nullable=True), s.str())).validate(None)
Пример #8
0
def test_any_of_nullable_outer():
    s.any_of((s.int(), s.str()), nullable=True).validate(None)