File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -132,14 +132,26 @@ def test_mock_patch_dict_resetall(mocker):
132
132
assert x == {"new" : 10 }
133
133
134
134
135
- def test_deprecated_mock (mock , tmpdir ):
135
+ def test_deprecated_mock (testdir ):
136
136
"""
137
137
Use backward-compatibility-only mock fixture to ensure complete coverage.
138
138
"""
139
- mock .patch ("os.listdir" , return_value = ["mocked" ])
140
- assert os .listdir (str (tmpdir )) == ["mocked" ]
141
- mock .stopall ()
142
- assert os .listdir (str (tmpdir )) == []
139
+ p1 = testdir .makepyfile (
140
+ """
141
+ import os
142
+
143
+ def test(mock, tmpdir):
144
+ mock.patch("os.listdir", return_value=["mocked"])
145
+ assert os.listdir(str(tmpdir)) == ["mocked"]
146
+ mock.stopall()
147
+ assert os.listdir(str(tmpdir)) == []
148
+ """
149
+ )
150
+ result = testdir .runpytest (str (p1 ))
151
+ result .stdout .fnmatch_lines (
152
+ ['*DeprecationWarning: "mock" fixture has been deprecated, use "mocker"*' ]
153
+ )
154
+ assert result .ret == 0
143
155
144
156
145
157
@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments