From 7fc42e84aa97be7679c52918cc0d10567117067f Mon Sep 17 00:00:00 2001 From: Phillip Schanely Date: Sun, 21 Jul 2024 20:45:05 -0400 Subject: [PATCH] Suppress errors for proxy-intolerant C functions --- hypothesis_crosshair_provider/__init__.py | 6 +++--- hypothesis_crosshair_provider/crosshair_provider.py | 8 +++++++- hypothesis_crosshair_provider/end_to_end_test.py | 11 +++++++++++ setup.py | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/hypothesis_crosshair_provider/__init__.py b/hypothesis_crosshair_provider/__init__.py index 654c4d9..a65c3c8 100644 --- a/hypothesis_crosshair_provider/__init__.py +++ b/hypothesis_crosshair_provider/__init__.py @@ -10,6 +10,6 @@ def _hypothesis_setup_hook(*a, **kw): "This version of hypothesis doesn't support the CrossHair backend" ) return - AVAILABLE_PROVIDERS[ - "crosshair" - ] = "hypothesis_crosshair_provider.crosshair_provider.CrossHairPrimitiveProvider" + AVAILABLE_PROVIDERS["crosshair"] = ( + "hypothesis_crosshair_provider.crosshair_provider.CrossHairPrimitiveProvider" + ) diff --git a/hypothesis_crosshair_provider/crosshair_provider.py b/hypothesis_crosshair_provider/crosshair_provider.py index 657d23a..59cb5a4 100644 --- a/hypothesis_crosshair_provider/crosshair_provider.py +++ b/hypothesis_crosshair_provider/crosshair_provider.py @@ -13,7 +13,8 @@ StateSpaceContext, UnexploredPath, VerificationStatus, condition_parser, context_statespace, get_current_parser, is_tracing, - proxy_for_type) + proxy_for_type, + suspected_proxy_intolerance_exception) from crosshair.libimpl.builtinslib import (LazyIntSymbolicStr, SymbolicBoundedIntTuple) from crosshair.statespace import DeatchedPathNode @@ -129,6 +130,11 @@ def per_test_case_context_manager(self): raise exc except (IgnoreAttempt, UnexploredPath): pass + except TypeError as exc: + if suspected_proxy_intolerance_exception(exc): + pass + else: + raise finally: self._previous_space = space if any_choices_made: diff --git a/hypothesis_crosshair_provider/end_to_end_test.py b/hypothesis_crosshair_provider/end_to_end_test.py index dee4056..f2f0086 100644 --- a/hypothesis_crosshair_provider/end_to_end_test.py +++ b/hypothesis_crosshair_provider/end_to_end_test.py @@ -1,4 +1,5 @@ import math +import os import re import pytest @@ -124,3 +125,13 @@ def a(self): @rule() def b(self): pass + + +def test_proxy_intolerance(): + @settings(backend="crosshair") + @given(st.text()) + def f(t): + # ideally we keep this up-to-date with some C function that will not accept symbolics: + os.fspath(t) + + f() diff --git a/setup.py b/setup.py index 11fdb05..4c43d9e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setuptools.setup( name="hypothesis-crosshair", - version="0.0.8", + version="0.0.9", author="Phillip Schanely", author_email="pschanely+B9vk@gmail.com", packages=setuptools.find_packages(), @@ -11,7 +11,7 @@ description="Level-up your Hypothesis tests with CrossHair.", long_description=open("README.md", encoding="utf-8").read(), long_description_content_type="text/markdown", - install_requires=["hypothesis>=6.104.2", "crosshair-tool>=0.0.58"], + install_requires=["hypothesis>=6.104.2", "crosshair-tool>=0.0.63"], python_requires=">=3.8", entry_points={ "hypothesis": ["_ = hypothesis_crosshair_provider:_hypothesis_setup_hook"]