@given(i=integers()) exploded with assertion error on assert min_value is not None. Huh?
Reproducer
Trivial do-nothing test case:
from hypothesis import given, settings
from hypothesis.strategies import integers
@given(i=integers())
@settings(max_examples=50000)
def test_dummy(i):
assert i is i
Run it with: pytest --hypothesis-seed=55662285600128535524272749666366957831 tgiven.py
On my machine it takes about 12 seconds until it asserts, but it asserts reliably.
Traceback
@given(i=integers())
> @settings(max_examples=50000)
tgiven.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/engine.py:543: in run
self._run()
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/engine.py:973: in _run
self.generate_new_examples()
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/engine.py:755: in generate_new_examples
prefix = self.generate_novel_prefix()
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/engine.py:399: in generate_novel_prefix
return self.tree.generate_novel_prefix(self.random)
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/datatree.py:766: in generate_novel_prefix
(v, buf) = self._draw_from_cache(
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/datatree.py:904: in _draw_from_cache
for v in generator:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ir_type = 'integer', kwargs = {'max_value': None, 'min_value': None, 'shrink_towards': 0, 'weights': None}
def all_children(ir_type, kwargs):
if ir_type == "integer":
min_value = kwargs["min_value"]
max_value = kwargs["max_value"]
weights = kwargs["weights"]
# it's a bit annoying (but completely feasible) to implement the cases
# other than "both sides bounded" here. We haven't needed to yet because
# in practice we don't struggle with unbounded integer generation.
> assert min_value is not None
E assert None is not None
/usr/lib/python3.12/site-packages/hypothesis/internal/conjecture/datatree.py:270: AssertionError
============================================= short test summary info ==============================================
FAILED tgiven.py::test_dummy - assert None is not None
Debug log generated with pytest --hypothesis-verbosity=debug --full-trace --hypothesis-seed=55662285600128535524272749666366957831 tgiven.py &> debug.log is attached here:
Versions tested
Summary
@given(i=integers())
exploded with assertion error onassert min_value is not None
. Huh?Reproducer
Trivial do-nothing test case:
Run it with:
pytest --hypothesis-seed=55662285600128535524272749666366957831 tgiven.py
On my machine it takes about 12 seconds until it asserts, but it asserts reliably.
Traceback
Debug log generated with
pytest --hypothesis-verbosity=debug --full-trace --hypothesis-seed=55662285600128535524272749666366957831 tgiven.py &> debug.log
is attached here:debug.log.gz