diff --git a/setup.py b/setup.py index e9dfa39..45bac84 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,13 @@ def read(fname): assert __version__ is not None REQUIREMENTS_DOCS = ["sphinx~=3.0", "alabaster~=0.7"] -TESTS_BASIC = ["pytest>=5.0", "pytest-sugar", "coverage"] +TESTS_BASIC = [ + "pytest>=5.0", + "pytest-sugar", + "coverage", + "pytest-mypy-plugins", + "types-mock", +] TESTS_NUMPY = ["numpy"] DEV_TOOLS = [ "towncrier", diff --git a/tests/type-hinting/core/core/test_is.yml b/tests/type-hinting/core/core/test_is.yml new file mode 100644 index 0000000..559be68 --- /dev/null +++ b/tests/type-hinting/core/core/test_is.yml @@ -0,0 +1,10 @@ +- case: is + main: | + from hamcrest import assert_that, is_, empty + from typing import Any, Sequence + + a: Sequence[Any] = [] + b = 99 + + assert_that(a, is_(empty())) + assert_that(b, is_(empty())) # E: Cannot infer type argument 1 of "assert_that" diff --git a/tests/type-hinting/core/test_assert_that.yml b/tests/type-hinting/core/test_assert_that.yml new file mode 100644 index 0000000..1a8f8a3 --- /dev/null +++ b/tests/type-hinting/core/test_assert_that.yml @@ -0,0 +1,9 @@ +- case: assert_that + main: | + from hamcrest import assert_that, instance_of, starts_with + + assert_that("string", starts_with("str")) + assert_that("str", instance_of(str)) + assert_that(99, starts_with("str")) + out: | + main:5: error: Cannot infer type argument 1 of "assert_that" diff --git a/tests/type-hinting/library/collection/test_empty.yml b/tests/type-hinting/library/collection/test_empty.yml new file mode 100644 index 0000000..3c10c43 --- /dev/null +++ b/tests/type-hinting/library/collection/test_empty.yml @@ -0,0 +1,6 @@ +- case: empty + main: | + from hamcrest import assert_that, is_, empty + + assert_that([], empty()) + assert_that(99, empty()) # E: Cannot infer type argument 1 of "assert_that" \ No newline at end of file diff --git a/tests/type-hinting/library/text/test_equal_to_ignoring_case.yml b/tests/type-hinting/library/text/test_equal_to_ignoring_case.yml new file mode 100644 index 0000000..8a61a39 --- /dev/null +++ b/tests/type-hinting/library/text/test_equal_to_ignoring_case.yml @@ -0,0 +1,10 @@ +- case: equal_to_ignoring_case + main: | + from hamcrest import equal_to_ignoring_case + + reveal_type(equal_to_ignoring_case("")) + equal_to_ignoring_case("") + equal_to_ignoring_case(99) + out: | + main:3: note: Revealed type is "hamcrest.core.matcher.Matcher[builtins.str]" + main:5: error: Argument 1 to "equal_to_ignoring_case" has incompatible type "int"; expected "str" diff --git a/tests/type-hinting/test_test_types.yml b/tests/type-hinting/test_test_types.yml deleted file mode 100644 index cfe9985..0000000 --- a/tests/type-hinting/test_test_types.yml +++ /dev/null @@ -1,5 +0,0 @@ -- case: equal_to_ignoring_case - main: | - from hamcrest.library.text.isequal_ignoring_case import equal_to_ignoring_case - - reveal_type(equal_to_ignoring_case("")) # N: Revealed type is "hamcrest.core.matcher.Matcher[builtins.str]"