Skip to content

Commit

Permalink
Fixes issue HypothesisWorks#3527
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksspirit committed Apr 24, 2023
1 parent 1f4986b commit 4163610
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -183,3 +183,4 @@ their individual contributions.
* `Yiyang Zhan <https://www.github.com/zhanpon>`_
* `Zac Hatfield-Dodds <https://www.github.com/Zac-HD>`_ (zac.hatfield.dodds@gmail.com)
* `Zebulun Arendsee <https://www.github.com/arendsee>`_ (zbwrnz@gmail.com)
* `Nick Muoh <https://github.com/OdinTech3>`_ (nickspirit3@gmail.com)
25 changes: 23 additions & 2 deletions hypothesis-python/tests/nocover/test_type_lookup.py
Expand Up @@ -8,11 +8,12 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.

from typing import Callable
from typing import Callable, Tuple
from dataclasses import dataclass

import pytest

from hypothesis import strategies as st
from hypothesis import given, strategies as st
from hypothesis.errors import InvalidArgument
from hypothesis.internal.compat import Concatenate, ParamSpec
from hypothesis.strategies._internal.types import NON_RUNTIME_TYPES
Expand Down Expand Up @@ -82,3 +83,23 @@ def test_callable_return_typegard_type():

with pytest.raises(InvalidArgument, match="Cannot register generic type"):
st.register_type_strategy(Callable[[], TypeGuard[int]], st.none())


@dataclass
class ItWorks:
a: dict[Tuple[int, int], str]


@dataclass
class ItDoesnt:
a: dict[tuple[int, int], str]


@given(st.from_type(ItWorks))
def test_tuple_from_typing_works(x: ItWorks):
assert len(x.a) >= 0


@given(st.from_type(ItDoesnt))
def test_tuple_from_builtin_works(x: ItDoesnt):
assert len(x.a) >= 0

0 comments on commit 4163610

Please sign in to comment.