Skip to content

Commit 15e235c

Browse files
authored
Remove obsolete "importorskip('unittest.mock')" calls (#5608)
Remove obsolete "importorskip('unittest.mock')" calls
2 parents 54e08b7 + 65c2301 commit 15e235c

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

testing/python/integration.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,22 @@ def f(x):
104104
values = getfuncargnames(f)
105105
assert values == ("x",)
106106

107-
@pytest.mark.xfail(
108-
strict=False, reason="getfuncargnames breaks if mock is imported"
109-
)
110-
def test_wrapped_getfuncargnames_patching(self):
107+
def test_getfuncargnames_patching(self):
111108
from _pytest.compat import getfuncargnames
109+
from unittest.mock import patch
112110

113-
def wrap(f):
114-
def func():
111+
class T:
112+
def original(self, x, y, z):
115113
pass
116114

117-
func.__wrapped__ = f
118-
func.patchings = ["qwe"]
119-
return func
120-
121-
@wrap
115+
@patch.object(T, "original")
122116
def f(x, y, z):
123117
pass
124118

125119
values = getfuncargnames(f)
126120
assert values == ("y", "z")
127121

128122
def test_unittest_mock(self, testdir):
129-
pytest.importorskip("unittest.mock")
130123
testdir.makepyfile(
131124
"""
132125
import unittest.mock
@@ -142,7 +135,6 @@ def test_hello(self, abspath):
142135
reprec.assertoutcome(passed=1)
143136

144137
def test_unittest_mock_and_fixture(self, testdir):
145-
pytest.importorskip("unittest.mock")
146138
testdir.makepyfile(
147139
"""
148140
import os.path
@@ -164,7 +156,6 @@ def test_hello(inject_me):
164156
reprec.assertoutcome(passed=1)
165157

166158
def test_unittest_mock_and_pypi_mock(self, testdir):
167-
pytest.importorskip("unittest.mock")
168159
pytest.importorskip("mock", "1.0.1")
169160
testdir.makepyfile(
170161
"""

0 commit comments

Comments
 (0)