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 @@ -129,14 +129,26 @@ def test_mock_patch_dict_resetall(mocker):
129
129
assert x == {"new" : 10 }
130
130
131
131
132
- def test_deprecated_mock (mock , tmpdir ):
132
+ def test_deprecated_mock (testdir ):
133
133
"""
134
134
Use backward-compatibility-only mock fixture to ensure complete coverage.
135
135
"""
136
- mock .patch ("os.listdir" , return_value = ["mocked" ])
137
- assert os .listdir (str (tmpdir )) == ["mocked" ]
138
- mock .stopall ()
139
- assert os .listdir (str (tmpdir )) == []
136
+ p1 = testdir .makepyfile (
137
+ """
138
+ import os
139
+
140
+ def test(mock, tmpdir):
141
+ mock.patch("os.listdir", return_value=["mocked"])
142
+ assert os.listdir(str(tmpdir)) == ["mocked"]
143
+ mock.stopall()
144
+ assert os.listdir(str(tmpdir)) == []
145
+ """
146
+ )
147
+ result = testdir .runpytest (str (p1 ))
148
+ result .stdout .fnmatch_lines (
149
+ ['*DeprecationWarning: "mock" fixture has been deprecated, use "mocker"*' ]
150
+ )
151
+ assert result .ret == 0
140
152
141
153
142
154
@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments