Skip to content

Commit

Permalink
Fixes CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Sep 3, 2021
1 parent d810abf commit f52cd03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def find_annotated_strategy(annotated_type): # pragma: no cover
)
for arg in all_args:
if is_annotated_type(arg):
flattened_meta.extend(find_annotated_strategy(arg))
flattened_meta.append(find_annotated_strategy(arg))
if isinstance(arg, st.SearchStrategy):
flattened_meta.append(arg)
return flattened_meta[-1] if flattened_meta else None
Expand Down
6 changes: 6 additions & 0 deletions hypothesis-python/tests/cover/test_lookup_py39.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_typing_Annotated(annotated_type, expected_strategy_repr):
PositiveInt = typing.Annotated[int, st.integers(min_value=1)]
MoreThenTenInt = typing.Annotated[PositiveInt, st.integers(min_value=10 + 1)]
WithTwoStrategies = typing.Annotated[int, st.integers(), st.none()]
ExtraAnnotationNoStrategy = Annotated[PositiveInt, "metadata"]


def arg_positive(x: PositiveInt):
Expand All @@ -68,6 +69,11 @@ def test_annotated_with_two_strategies(data):
assert data.draw(st.from_type(WithTwoStrategies)) is None


@given(st.data())
def test_annotated_extra_metadata(data):
assert data.draw(st.from_type(ExtraAnnotationNoStrategy)) > 0


@dataclasses.dataclass
class User:
id: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_typing_extensions_Annotated(annotated_type, expected_strategy_repr):
PositiveInt = Annotated[int, st.integers(min_value=1)]
MoreThenTenInt = Annotated[PositiveInt, st.integers(min_value=10 + 1)]
WithTwoStrategies = Annotated[int, st.integers(), st.none()]
ExtraAnnotationNoStrategy = Annotated[PositiveInt, "metadata"]


def arg_positive(x: PositiveInt):
Expand All @@ -125,3 +126,8 @@ def test_annotated_more_than_ten(data):
@given(st.data())
def test_annotated_with_two_strategies(data):
assert data.draw(st.from_type(WithTwoStrategies)) is None


@given(st.data())
def test_annotated_extra_metadata(data):
assert data.draw(st.from_type(ExtraAnnotationNoStrategy)) > 0

0 comments on commit f52cd03

Please sign in to comment.