Skip to content

Commit 21c4c41

Browse files
committed
Test with CPython 3.10-dev
1 parent 88426e5 commit 21c4c41

File tree

8 files changed

+42
-13
lines changed

8 files changed

+42
-13
lines changed

.github/workflows/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- check-pypy37
2525
- check-py38
2626
- check-py39
27+
- check-py310
2728
- check-quality
2829
- lint-ruby
2930
- check-ruby-tests

hypothesis-python/scripts/basic-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pip install lark-parser==0.7.1
4444
$PYTEST tests/lark/
4545
pip uninstall -y lark-parser
4646

47-
if [ "$(python -c 'import platform; print(platform.python_implementation() != "PyPy")')" = "True" ] ; then
47+
if [ "$(python -c $'import platform, sys; print(sys.version_info.releaselevel == \'final\' and platform.python_implementation() != "PyPy")')" = "True" ] ; then
4848
pip install ".[codemods,cli]"
4949
$PYTEST tests/codemods/
5050
pip uninstall -y libcst click

hypothesis-python/tests/cover/test_annotations.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#
1414
# END HEADER
1515

16+
import sys
1617
from inspect import getfullargspec
1718

1819
import attr
@@ -115,7 +116,8 @@ def test_composite_edits_annotations():
115116
@pytest.mark.parametrize("nargs", [1, 2, 3])
116117
def test_given_edits_annotations(nargs):
117118
spec_given = getfullargspec(given(*(nargs * [st.none()]))(pointless_composite))
118-
assert spec_given.annotations.pop("return") is None
119+
expected = None if sys.version_info[:2] < (3, 10) else type(None)
120+
assert spec_given.annotations.pop("return") == expected
119121
assert len(spec_given.annotations) == 3 - nargs
120122

121123

hypothesis-python/tests/cover/test_lookup.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,16 @@ def test_distinct_typevars_distinct_type():
337337
)
338338

339339

340-
@given(st.data())
341-
def test_same_typevars_same_type(data):
342-
"""Ensures that single type argument will always have the same type in a single context."""
343-
A = typing.TypeVar("A")
340+
A = typing.TypeVar("A")
344341

345-
def same_type_args(a: A, b: A):
346-
assert type(a) == type(b)
347342

348-
data.draw(st.builds(same_type_args))
343+
def same_type_args(a: A, b: A):
344+
assert type(a) == type(b)
345+
346+
347+
@given(st.builds(same_type_args))
348+
def test_same_typevars_same_type(_):
349+
"""Ensures that single type argument will always have the same type in a single context."""
349350

350351

351352
def test_typevars_can_be_redefined():
@@ -755,7 +756,12 @@ def test_compat_get_type_hints_aware_of_None_default():
755756
find_any(strategy, lambda x: x.a is not None)
756757

757758
assert typing.get_type_hints(constructor)["a"] == typing.Optional[str]
758-
assert inspect.signature(constructor).parameters["a"].annotation == str
759+
annotation = inspect.signature(constructor).parameters["a"].annotation
760+
assert annotation == str or (
761+
# See https://bugs.python.org/issue43006
762+
annotation == typing.Optional[str]
763+
and sys.version_info[:2] >= (3, 10)
764+
)
759765

760766

761767
_ValueType = typing.TypeVar("_ValueType")

hypothesis-python/tests/cover/test_lookup_py38.py

+13
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# END HEADER
1515

1616
import dataclasses
17+
import sys
1718
import typing
1819

1920
import pytest
@@ -98,6 +99,18 @@ def test_typeddict_with_optional_then_required_again(value):
9899
assert isinstance(value["c"], str)
99100

100101

102+
class NestedDict(typing.TypedDict):
103+
inner: A
104+
105+
106+
@pytest.mark.skipif(sys.version_info[:2] >= (3, 10), reason="see issue #2897")
107+
@given(from_type(NestedDict))
108+
def test_typeddict_with_nested_value(value):
109+
assert type(value) == dict
110+
assert set(value) == {"inner"}
111+
assert isinstance(value["inner"]["a"], int)
112+
113+
101114
@pytest.mark.xfail
102115
def test_layered_optional_key_is_optional():
103116
# Optional keys are not currently supported, as PEP-589 leaves no traces

hypothesis-python/tests/cover/test_randoms.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import inspect
1717
import math
18+
import sys
1819
from copy import copy
1920

2021
import pytest
@@ -97,7 +98,7 @@ def any_call_of_method(draw, method):
9798
b = draw(INT64)
9899
assume(a != b)
99100
a, b = sorted((a, b))
100-
if a == 0 and draw(st.booleans()):
101+
if a == 0 and sys.version_info[:2] < (3, 10) and draw(st.booleans()):
101102
start = b
102103
stop = None
103104
else:

hypothesis-python/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{36,py36,37,py37,38,39}-{brief,prettyquick,full,custom}
2+
envlist = py{36,py36,37,py37,38,39,310}-{brief,prettyquick,full,custom}
33
toxworkdir={env:TOX_WORK_DIR:.tox}
44

55
[testenv]

tooling/src/hypothesistooling/__main__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,15 @@ def run_tox(task, version):
312312
PY37 = "3.7.10"
313313
PY38 = PYMAIN = "3.8.8" # Note: keep this in sync with build.sh and GH Actions main.yml
314314
PY39 = "3.9.2"
315+
PY310 = "3.10-dev"
315316
PYPY36 = "pypy3.6-7.3.1"
316317
PYPY37 = "pypy3.7-7.3.2"
317318

318319

319320
# ALIASES are the executable names for each Python version
320321
ALIASES = {PYPY36: "pypy3", PYPY37: "pypy3"}
321322

322-
for n in [PY36, PY37, PY38, PY39]:
323+
for n in [PY36, PY37, PY38, PY39, PY310]:
323324
major, minor, patch = n.replace("-dev", ".").split(".")
324325
ALIASES[n] = f"python{major}.{minor}"
325326

@@ -353,6 +354,11 @@ def check_py39():
353354
run_tox("py39-full", PY39)
354355

355356

357+
@python_tests
358+
def check_py310():
359+
run_tox("py310-full", PY310)
360+
361+
356362
@python_tests
357363
def check_pypy36():
358364
run_tox("pypy3-full", PYPY36)

0 commit comments

Comments
 (0)