Skip to content

Commit f128a23

Browse files
authored
Merge pull request #273 from nicoddemus/asyncio-272
2 parents 3ca933a + cb4d567 commit f128a23

File tree

7 files changed

+61
-15
lines changed

7 files changed

+61
-15
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python: ["3.6", "3.7", "3.8", "3.9"]
13+
python: ["3.7", "3.8", "3.9", "3.10"]
1414
os: [ubuntu-latest, windows-latest]
1515
include:
16-
- python: "3.6"
17-
tox_env: "py36"
1816
- python: "3.7"
1917
tox_env: "py37"
2018
- python: "3.8"
2119
tox_env: "py38"
2220
- python: "3.9"
2321
tox_env: "py39"
22+
- python: "3.10"
23+
tox_env: "py310"
2424

2525
steps:
2626
- uses: actions/checkout@v1

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
3.7.0 (UNRELEASED)
2+
------------------
3+
4+
* Python 3.10 now officially supported.
5+
* Dropped support for Python 3.6.
6+
17
3.6.1 (2021-05-06)
28
------------------
39

File renamed without changes.

mypy.ini

Lines changed: 1 addition & 0 deletions
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

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
package_data={
1313
"pytest_mock": ["py.typed"],
1414
},
15-
python_requires=">=3.6",
15+
python_requires=">=3.7",
1616
install_requires=["pytest>=5.0"],
1717
use_scm_version={"write_to": "src/pytest_mock/_version.py"},
1818
setup_requires=["setuptools_scm"],
@@ -31,10 +31,10 @@
3131
"License :: OSI Approved :: MIT License",
3232
"Operating System :: OS Independent",
3333
"Programming Language :: Python :: 3",
34-
"Programming Language :: Python :: 3.6",
3534
"Programming Language :: Python :: 3.7",
3635
"Programming Language :: Python :: 3.8",
3736
"Programming Language :: Python :: 3.9",
37+
"Programming Language :: Python :: 3.10",
3838
"Programming Language :: Python :: 3 :: Only",
3939
"Topic :: Software Development :: Testing",
4040
],

tests/test_pytest_mock.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_repr_with_no_name(self, mocker: MockerFixture) -> None:
211211
def test_repr_with_name(self, mocker: MockerFixture) -> None:
212212
test_name = "funny walk"
213213
stub = mocker.stub(name=test_name)
214-
assert "name={!r}".format(test_name) in repr(stub)
214+
assert f"name={test_name!r}" in repr(stub)
215215

216216
def __test_failure_message(self, mocker: MockerFixture, **kwargs: Any) -> None:
217217
expected_name = kwargs.get("name") or "mock"
@@ -267,19 +267,19 @@ def test_instance_method_spy_exception(
267267
) -> None:
268268
class Foo:
269269
def bar(self, arg):
270-
raise exc_cls("Error with {}".format(arg))
270+
raise exc_cls(f"Error with {arg}")
271271

272272
foo = Foo()
273273
spy = mocker.spy(foo, "bar")
274274

275275
expected_calls = []
276276
for i, v in enumerate([10, 20]):
277-
with pytest.raises(exc_cls, match="Error with {}".format(v)):
277+
with pytest.raises(exc_cls, match=f"Error with {v}"):
278278
foo.bar(arg=v)
279279

280280
expected_calls.append(mocker.call(arg=v))
281281
assert foo.bar.call_args_list == expected_calls # type:ignore[attr-defined]
282-
assert str(spy.spy_exception) == "Error with {}".format(v)
282+
assert str(spy.spy_exception) == f"Error with {v}"
283283

284284

285285
def test_instance_method_spy_autospec_true(mocker: MockerFixture) -> None:
@@ -296,7 +296,7 @@ def bar(self, arg):
296296

297297

298298
def test_spy_reset(mocker: MockerFixture) -> None:
299-
class Foo(object):
299+
class Foo:
300300
def bar(self, x):
301301
if x == 0:
302302
raise ValueError("invalid x")
@@ -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 3.5.3
3-
envlist = py{35,36,37,38,39}, linting, norewrite
3+
envlist = py{37,38,39,310}, linting, norewrite
44

55
[testenv]
66
passenv = USER USERNAME
@@ -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)