Skip to content

Commit 8cf60be

Browse files
committed
Fix tests for Python 3.11
1 parent bae8013 commit 8cf60be

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

hypothesis-python/src/hypothesis/internal/escalation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_trimmed_traceback(exception=None):
9494
return tb
9595
while tb.tb_next is not None and (
9696
# If the frame is from one of our files, it's been added by Hypothesis.
97-
is_hypothesis_file(getframeinfo(tb.tb_frame)[0])
97+
is_hypothesis_file(getframeinfo(tb.tb_frame).filename)
9898
# But our `@proxies` decorator overrides the source location,
9999
# so we check for an attribute it injects into the frame too.
100100
or tb.tb_frame.f_globals.get("__hypothesistracebackhide__") is True

hypothesis-python/src/hypothesis/strategies/_internal/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
# that this value can't be reassigned.
101101
NON_RUNTIME_TYPES = frozenset(
102102
(
103+
typing.Any,
103104
*ClassVarTypes,
104105
*TypeAliasTypes,
105106
*FinalTypes,

hypothesis-python/tests/conftest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@
3838
collect_ignore_glob.append("cover/test_asyncio.py") # @asyncio.coroutine removed
3939

4040
assert sys.version_info.releaselevel == "alpha"
41-
# These seem to fail due to traceback rendering failures, TODO fix the tests
41+
# TODO: our traceback elision doesn't work with Python 3.11's nice new format yet
4242
collect_ignore_glob.append("cover/test_traceback_elision.py")
4343
collect_ignore_glob.append("pytest/test_capture.py")
44-
# Changes to type-annotation inspection, TODO fix during the beta phase
45-
collect_ignore_glob.append("cover/test_lookup.py")
46-
collect_ignore_glob.append("cover/test_lookup_py37.py")
4744

4845

4946
def pytest_configure(config):

hypothesis-python/tests/cover/test_lookup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io
1818
import re
1919
import string
20+
import sys
2021
import typing
2122
from inspect import signature
2223
from numbers import Real
@@ -770,7 +771,11 @@ def test_compat_get_type_hints_aware_of_None_default():
770771
find_any(strategy, lambda x: x.a is None)
771772
find_any(strategy, lambda x: x.a is not None)
772773

773-
assert typing.get_type_hints(constructor)["a"] == typing.Optional[str]
774+
if sys.version_info[:2] >= (3, 11):
775+
# https://docs.python.org/3.11/library/typing.html#typing.get_type_hints
776+
assert typing.get_type_hints(constructor)["a"] == str
777+
else:
778+
assert typing.get_type_hints(constructor)["a"] == typing.Optional[str]
774779
assert inspect.signature(constructor).parameters["a"].annotation == str
775780

776781

hypothesis-python/tests/cover/test_lookup_py37.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ def test_resolving_standard_callable_ellipsis(x: collections.abc.Callable[..., E
163163
assert isinstance(x(1, 2, 3, a=4, b=5, c=6), Elem)
164164

165165

166+
@pytest.mark.skipif(
167+
sys.version_info[:3] == (3, 11, 0),
168+
reason="https://github.com/python/cpython/issues/91621",
169+
)
166170
@given(...)
167171
def test_resolving_standard_callable_no_args(x: collections.abc.Callable[[], Elem]):
168172
assert isinstance(x, collections.abc.Callable)

0 commit comments

Comments
 (0)