Skip to content

Commit 7c7375c

Browse files
committed
move tuple subclass test to py39
1 parent e398b28 commit 7c7375c

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

hypothesis-python/tests/cover/test_lookup.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,27 +1069,3 @@ def test_tuple_subclasses_not_generic_sequences():
10691069
with temp_registered(TupleSubtype, st.builds(TupleSubtype)):
10701070
s = st.from_type(typing.Sequence[int])
10711071
assert_no_examples(s, lambda x: isinstance(x, tuple))
1072-
1073-
1074-
T = typing.TypeVar("T")
1075-
1076-
1077-
@typing.runtime_checkable
1078-
class Fooable(typing.Protocol[T]):
1079-
def foo(self):
1080-
...
1081-
1082-
1083-
class FooableConcrete(tuple):
1084-
def foo(self):
1085-
pass
1086-
1087-
1088-
def test_only_tuple_subclasses_in_typing_type():
1089-
# A generic typing type (such as Fooable) whose only concrete
1090-
# instantiations are tuples should still generate tuples. This is in
1091-
# contrast to test_tuple_subclasses_not_generic_sequences, which discards
1092-
# tuples if there are any alternatives.
1093-
with temp_registered(FooableConcrete, st.builds(FooableConcrete)):
1094-
s = st.from_type(Fooable[int])
1095-
assert_all_examples(s, lambda x: type(x) is FooableConcrete)

hypothesis-python/tests/cover/test_lookup_py39.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,27 @@ def test_can_register_builtin_list():
125125
st.from_type(list[int]),
126126
lambda ls: len(ls) <= 2 and {type(x) for x in ls}.issubset({int}),
127127
)
128+
129+
130+
T = typing.TypeVar("T")
131+
132+
133+
@typing.runtime_checkable
134+
class Fooable(typing.Protocol[T]):
135+
def foo(self):
136+
...
137+
138+
139+
class FooableConcrete(tuple):
140+
def foo(self):
141+
pass
142+
143+
144+
def test_only_tuple_subclasses_in_typing_type():
145+
# A generic typing type (such as Fooable) whose only concrete
146+
# instantiations are tuples should still generate tuples. This is in
147+
# contrast to test_tuple_subclasses_not_generic_sequences, which discards
148+
# tuples if there are any alternatives.
149+
with temp_registered(FooableConcrete, st.builds(FooableConcrete)):
150+
s = st.from_type(Fooable[int])
151+
assert_all_examples(s, lambda x: type(x) is FooableConcrete)

0 commit comments

Comments
 (0)