Esempio n. 1
0
def test_good_inp():
    expected_res = Db(
        metadata=good_inp['metadata'],
        flags={Flag('f1'), Flag('f2')},
        rows=[Row('Hello', (1, 2, 3)),
              Row('World', (4, 5, 6))],
        size=MemOptions.MEDIUM,
        attributes=Attributes.READ | Attributes.WRITE | Attributes.EXECUTE,
    )
    assert parse_input(good_inp, Db) == expected_res
Esempio n. 2
0
def test_literal():
    assert parse_input(5, Literal[5, Literal[1, 3]]) == 5
Esempio n. 3
0
def test_none():
    assert parse_input(None, None) is None
    with pytest.raises(ValidationError):
        parse_input("Some value", None)
Esempio n. 4
0
def test_arbitrary_valid(db):
    parse_input(db, Db)
Esempio n. 5
0
def test_collections():
    assert parse_input([1, 2, 3], frozenset) == frozenset((1, 2, 3))
    with pytest.raises(ValidationError):
        parse_input([{1}, 2, 3], frozenset)
    with pytest.raises(ValidationError):
        parse_input("X", frozenset)
Esempio n. 6
0
def test_not_supported():
    with pytest.raises(NotImplementedError):
        parse_input(5, Callable[[int], set])
Esempio n. 7
0
def test_bad_inp():
    for k in bad_inp:
        with pytest.raises(ValidationError):
            parse_input(*k)