Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integers strategy can fail with assertion error: assert min_value is not None #3974

Closed
pspacek opened this issue May 6, 2024 · 0 comments · Fixed by #3983
Closed

integers strategy can fail with assertion error: assert min_value is not None #3974

pspacek opened this issue May 6, 2024 · 0 comments · Fixed by #3983
Assignees
Labels
bug something is clearly wrong here

Comments

@pspacek
Copy link

pspacek commented May 6, 2024

Versions tested

  • hypothesis 6.100.4
  • Python 3.12.3
  • pytest 8.2.0

Summary

@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:

debug.log.gz

@tybug tybug added the bug something is clearly wrong here label May 6, 2024
@tybug tybug self-assigned this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is clearly wrong here
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants