pschanely / hypothesis-crosshair

Level-up your Hypothesis tests with CrossHair
MIT License
8 stars 0 forks source link

Two problems on first try #5

Closed jobh closed 5 months ago

jobh commented 5 months ago

Hi,

I was curious to try hypothesis-crosshair, this is just reporting some issues which popped up in my first attempt.

1. Import of deprecated package

  File "/home/jobh/mambaforge/envs/hypothesis/lib/python3.11/site-packages/crosshair/libimpl/relib.py", line 2, in <module>
    from sre_parse import ANY  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jobh/mambaforge/envs/hypothesis/lib/python3.11/sre_parse.py", line 2, in <module>
    warnings.warn(f"module {__name__!r} is deprecated",
DeprecationWarning: module 'sre_parse' is deprecated
================================================================================= short test summary info ==================================================================================
FAILED crosshair/test_basic.py::test_needs_solver - DeprecationWarning: module 'sre_parse' is deprecated
==================================================================================== 1 failed in 0.07s =====================================================================================

I think this package should be imported as re._parser in python 3.11+. Next, with -Wignore:

2. Error on first run

  File "/home/jobh/src/hypothesis/crosshair/test_basic.py", line 4, in test_needs_solver
    @given(st.integers())
                   ^^^
  File "/home/jobh/src/hypothesis/hypothesis-python/src/hypothesis/core.py", line 1658, in wrapped_test
    raise the_error_hypothesis_found
  File "/home/jobh/mambaforge/envs/hypothesis/lib/python3.11/site-packages/crosshair/libimpl/builtinslib.py", line 1101, in __hash__
    return self.__index__().__hash__()
           ^^^^^^^^^^^^^^^^
  File "/home/jobh/mambaforge/envs/hypothesis/lib/python3.11/site-packages/crosshair/libimpl/builtinslib.py", line 1112, in __index__
    space = context_statespace()
            ^^^^^^^^^^^^^^^^^^^^
  File "/home/jobh/mambaforge/envs/hypothesis/lib/python3.11/site-packages/crosshair/statespace.py", line 247, in context_statespace
    raise CrosshairInternal
crosshair.util.CrosshairInternal
================================================================================= short test summary info ==================================================================================
FAILED crosshair/test_basic.py::test_needs_solver - crosshair.util.CrosshairInternal
==================================================================================== 1 failed in 0.13s =====================================================================================

Interestingly, this failure goes away if I run again (until the .hypothesis db directory is removed). So it seems that the example has been found, and has been recorded by hypothesis, before the error happens.

================================================================================= short test summary info ==================================================================================
FAILED crosshair/test_basic.py::test_needs_solver - assert 123456789 != 123456789
==================================================================================== 1 failed in 0.37s =====================================================================================

(yay!)

tybug commented 5 months ago

I think the latter is very likely to be https://github.com/HypothesisWorks/hypothesis/pull/4022, seems to be fixed with that branch

pschanely commented 5 months ago

And I just pushed CrossHair v0.0.56 which should remove the sre_parse deprecation warnings (thanks for the suggested fix!).

jobh commented 5 months ago

I can confirm both these issues are resolved, with the post-test-case-hook-fix branch and crosshair-tool=0.0.56. Thanks!

Although the warning is replaced by this on Python 3.12:

  File "/home/jobh/mambaforge/envs/hyp/lib/python3.12/site-packages/crosshair/libimpl/builtinslib.py", line 3625, in <module>
    class BytesLike(collections.abc.ByteString, AbcString, CrossHairValue):
[...]
DeprecationWarning: 'collections.abc.ByteString' is deprecated and slated for removal in Python 3.14

sorry :-) Feel free to close this issue, especially if python 3.12 is not a supported platform (yet).

pschanely commented 5 months ago

Heh, don't apologize - I just noticed the same; please hold. 3.12 isn't less supported than other versions ... we run the full test suite on 3.12, but don't have warnings on. 😅

pschanely commented 5 months ago

@jobh The 3.12 warnings should be resolved too as of v0.0.57!

jobh commented 5 months ago

Thanks @pschanely! It works perfectly now.