Exemplo n.º 1
0
def test_supportscast_types_support_protocol_or_are_castable(protocol, typ, data):
    value = data.draw(st.from_type(protocol))
    # check that we aren't somehow generating instances of the protocol itself
    assert value.__class__ != protocol
    # test values drawn from the protocol types either support the protocol
    # or can be cast to typ
    assert issubclass(type(value), protocol) or types.can_cast(typ, value)
Exemplo n.º 2
0
def test_can_cast():
    assert types.can_cast(int, "0")
    assert not types.can_cast(int, "abc")