コード例 #1
0
ファイル: test_schema.py プロジェクト: lliu8080/roax
 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
ファイル: test_schema.py プロジェクト: lliu8080/roax
 def test_any_of_none_match(self):
     self._error(s.any_of([s.str(), s.int()]).validate, 123.45)
コード例 #3
0
ファイル: test_schema.py プロジェクト: lliu8080/roax
 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)