The following test demonstrates this bug:
@settings(max_examples=1000)
@given(type_=st.from_type(xrange))
def test_from_type_xrange(type_):
pass
OverflowError: Python int too large to convert to C long
I think our test suite is missing the following test, which should be added to tests/cover/test_type_lookup.py:
from hypothesis.searchstrategy.types import _global_type_lookup
@pytest.mark.parametrize("typ", sorted(_global_type_lookup, key=str))
@given(data())
def test_can_generate_from_all_registered_types(data, typ):
ex = data.draw(from_type(typ))
assert isinstance(ex, typ)
Everything looks fine for Python 2 once I make the xrange fix.
It looks like there are a few complications even on the Python 3 end of things because of the items from the typing module. Calling isinstance with some of these doesn't work. How do you want to proceed with these items:
SupportsXXXX objects we get: TypeError: Protocols cannot be used with isinstance().BytesIO & StringIO values are not instances of their typing counterparts.typing.Type fails with: where False = isinstance(+CT_co, typing.Type)I can make a mapping back to the appropriate types that gets used within the test for the first two points, and that should take care of those easily enough. I am not sure what to make of the typing.Type case.
I'd just exclude anything where the __module__ attribute is "typing"; as the runtime issues are more trouble than they're worth and well tested in the py3 tests.
That's a relief. Much simpler.