Skip to content

Commit

Permalink
move tuple subclass test to py39
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Oct 15, 2023
1 parent e398b28 commit 7c7375c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 0 additions & 24 deletions hypothesis-python/tests/cover/test_lookup.py
Expand Up @@ -1069,27 +1069,3 @@ def test_tuple_subclasses_not_generic_sequences():
with temp_registered(TupleSubtype, st.builds(TupleSubtype)):
s = st.from_type(typing.Sequence[int])
assert_no_examples(s, lambda x: isinstance(x, tuple))


T = typing.TypeVar("T")


@typing.runtime_checkable
class Fooable(typing.Protocol[T]):
def foo(self):
...


class FooableConcrete(tuple):
def foo(self):
pass


def test_only_tuple_subclasses_in_typing_type():
# A generic typing type (such as Fooable) whose only concrete
# instantiations are tuples should still generate tuples. This is in
# contrast to test_tuple_subclasses_not_generic_sequences, which discards
# tuples if there are any alternatives.
with temp_registered(FooableConcrete, st.builds(FooableConcrete)):
s = st.from_type(Fooable[int])
assert_all_examples(s, lambda x: type(x) is FooableConcrete)
24 changes: 24 additions & 0 deletions hypothesis-python/tests/cover/test_lookup_py39.py
Expand Up @@ -125,3 +125,27 @@ def test_can_register_builtin_list():
st.from_type(list[int]),
lambda ls: len(ls) <= 2 and {type(x) for x in ls}.issubset({int}),
)


T = typing.TypeVar("T")


@typing.runtime_checkable
class Fooable(typing.Protocol[T]):
def foo(self):
...


class FooableConcrete(tuple):
def foo(self):
pass


def test_only_tuple_subclasses_in_typing_type():
# A generic typing type (such as Fooable) whose only concrete
# instantiations are tuples should still generate tuples. This is in
# contrast to test_tuple_subclasses_not_generic_sequences, which discards
# tuples if there are any alternatives.
with temp_registered(FooableConcrete, st.builds(FooableConcrete)):
s = st.from_type(Fooable[int])
assert_all_examples(s, lambda x: type(x) is FooableConcrete)

0 comments on commit 7c7375c

Please sign in to comment.