diff --git a/mypy.ini b/mypy.ini index 2b6bae7..2daaec5 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,6 +2,7 @@ disallow_any_generics = True disallow_incomplete_defs = True disallow_subclassing_any = True +ignore_missing_imports = True no_implicit_optional = True pretty = True show_error_codes = True diff --git a/tests/test_pytest_mock.py b/tests/test_pytest_mock.py index 6d8feda..da20cf6 100644 --- a/tests/test_pytest_mock.py +++ b/tests/test_pytest_mock.py @@ -475,7 +475,6 @@ def __call__(self, x): assert spy.spy_return == 20 -@pytest.mark.asyncio async def test_instance_async_method_spy(mocker: MockerFixture) -> None: class Foo: async def bar(self, arg): @@ -728,6 +727,12 @@ def test_foo(mocker): @pytest.mark.usefixtures("needs_assert_rewrite") def test_detailed_introspection(testdir: Any) -> None: """Check that the "mock_use_standalone" is being used.""" + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ def test(mocker): @@ -769,11 +774,16 @@ def test(mocker): @pytest.mark.usefixtures("needs_assert_rewrite") def test_detailed_introspection_async(testdir: Any) -> None: """Check that the "mock_use_standalone" is being used.""" + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ import pytest - @pytest.mark.asyncio async def test(mocker): m = mocker.AsyncMock() await m('fo') @@ -824,6 +834,12 @@ def test_assert_called_with_unicode_arguments(mocker: MockerFixture) -> None: def test_plain_stopall(testdir: Any) -> None: """patch.stopall() in a test should not cause an error during unconfigure (#137)""" + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ import random @@ -958,6 +974,12 @@ def test_foo(mocker): def test_used_with_class_scope(testdir: Any) -> None: + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ import pytest @@ -982,6 +1004,12 @@ def test_get_random_number(self): def test_used_with_module_scope(testdir: Any) -> None: + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ import pytest @@ -1004,7 +1032,12 @@ def test_get_random_number(): def test_used_with_package_scope(testdir: Any) -> None: - """...""" + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ import pytest @@ -1027,7 +1060,12 @@ def test_get_random_number(): def test_used_with_session_scope(testdir: Any) -> None: - """...""" + testdir.makeini( + """ + [pytest] + asyncio_mode=auto + """ + ) testdir.makepyfile( """ import pytest diff --git a/tox.ini b/tox.ini index 5a2030a..784f892 100644 --- a/tox.ini +++ b/tox.ini @@ -28,6 +28,7 @@ commands = mypy {posargs:src tests} [pytest] addopts = -r a +asyncio_mode = auto [flake8] max-line-length = 88