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
def test_literal(): assert parse_input(5, Literal[5, Literal[1, 3]]) == 5
def test_none(): assert parse_input(None, None) is None with pytest.raises(ValidationError): parse_input("Some value", None)
def test_arbitrary_valid(db): parse_input(db, Db)
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)
def test_not_supported(): with pytest.raises(NotImplementedError): parse_input(5, Callable[[int], set])
def test_bad_inp(): for k in bad_inp: with pytest.raises(ValidationError): parse_input(*k)