Skip to content

Commit 0b869db

Browse files
committed
Configure asyncio_mode to fix tests
Fix #272
1 parent 3ca933a commit 0b869db

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

mypy.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
disallow_any_generics = True
33
disallow_incomplete_defs = True
44
disallow_subclassing_any = True
5+
ignore_missing_imports = True
56
no_implicit_optional = True
67
pretty = True
78
show_error_codes = True

tests/test_pytest_mock.py

+42-4
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ def __call__(self, x):
475475
assert spy.spy_return == 20
476476

477477

478-
@pytest.mark.asyncio
479478
async def test_instance_async_method_spy(mocker: MockerFixture) -> None:
480479
class Foo:
481480
async def bar(self, arg):
@@ -728,6 +727,12 @@ def test_foo(mocker):
728727
@pytest.mark.usefixtures("needs_assert_rewrite")
729728
def test_detailed_introspection(testdir: Any) -> None:
730729
"""Check that the "mock_use_standalone" is being used."""
730+
testdir.makeini(
731+
"""
732+
[pytest]
733+
asyncio_mode=auto
734+
"""
735+
)
731736
testdir.makepyfile(
732737
"""
733738
def test(mocker):
@@ -769,11 +774,16 @@ def test(mocker):
769774
@pytest.mark.usefixtures("needs_assert_rewrite")
770775
def test_detailed_introspection_async(testdir: Any) -> None:
771776
"""Check that the "mock_use_standalone" is being used."""
777+
testdir.makeini(
778+
"""
779+
[pytest]
780+
asyncio_mode=auto
781+
"""
782+
)
772783
testdir.makepyfile(
773784
"""
774785
import pytest
775786
776-
@pytest.mark.asyncio
777787
async def test(mocker):
778788
m = mocker.AsyncMock()
779789
await m('fo')
@@ -824,6 +834,12 @@ def test_assert_called_with_unicode_arguments(mocker: MockerFixture) -> None:
824834

825835
def test_plain_stopall(testdir: Any) -> None:
826836
"""patch.stopall() in a test should not cause an error during unconfigure (#137)"""
837+
testdir.makeini(
838+
"""
839+
[pytest]
840+
asyncio_mode=auto
841+
"""
842+
)
827843
testdir.makepyfile(
828844
"""
829845
import random
@@ -958,6 +974,12 @@ def test_foo(mocker):
958974

959975

960976
def test_used_with_class_scope(testdir: Any) -> None:
977+
testdir.makeini(
978+
"""
979+
[pytest]
980+
asyncio_mode=auto
981+
"""
982+
)
961983
testdir.makepyfile(
962984
"""
963985
import pytest
@@ -982,6 +1004,12 @@ def test_get_random_number(self):
9821004

9831005

9841006
def test_used_with_module_scope(testdir: Any) -> None:
1007+
testdir.makeini(
1008+
"""
1009+
[pytest]
1010+
asyncio_mode=auto
1011+
"""
1012+
)
9851013
testdir.makepyfile(
9861014
"""
9871015
import pytest
@@ -1004,7 +1032,12 @@ def test_get_random_number():
10041032

10051033

10061034
def test_used_with_package_scope(testdir: Any) -> None:
1007-
"""..."""
1035+
testdir.makeini(
1036+
"""
1037+
[pytest]
1038+
asyncio_mode=auto
1039+
"""
1040+
)
10081041
testdir.makepyfile(
10091042
"""
10101043
import pytest
@@ -1027,7 +1060,12 @@ def test_get_random_number():
10271060

10281061

10291062
def test_used_with_session_scope(testdir: Any) -> None:
1030-
"""..."""
1063+
testdir.makeini(
1064+
"""
1065+
[pytest]
1066+
asyncio_mode=auto
1067+
"""
1068+
)
10311069
testdir.makepyfile(
10321070
"""
10331071
import pytest

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ commands = mypy {posargs:src tests}
2828

2929
[pytest]
3030
addopts = -r a
31+
asyncio_mode = auto
3132

3233
[flake8]
3334
max-line-length = 88

0 commit comments

Comments
 (0)