18
18
19
19
20
20
@pytest .fixture
21
- def diag_mp (monkeypatch ):
21
+ def last_diagnostics_monkeypatch (monkeypatch ):
22
+ # gets called before every test altering last_diagnostics in order to reset it
22
23
monkeypatch .setattr (plugin , "last_diagnostics" , collections .defaultdict (list ))
23
24
return monkeypatch
24
25
@@ -45,7 +46,7 @@ def test_settings():
45
46
assert settings == {"plugins" : {"pylsp_mypy" : {}}}
46
47
47
48
48
- def test_plugin (workspace , diag_mp ):
49
+ def test_plugin (workspace , last_diagnostics_monkeypatch ):
49
50
config = FakeConfig ()
50
51
doc = Document (DOC_URI , workspace , DOC_TYPE_ERR )
51
52
plugin .pylsp_settings (config )
@@ -92,7 +93,7 @@ def test_parse_line_with_context(monkeypatch, word, bounds, workspace):
92
93
assert diag ["range" ]["end" ] == {"line" : 278 , "character" : bounds [1 ]}
93
94
94
95
95
- def test_multiple_workspaces (tmpdir , diag_mp ):
96
+ def test_multiple_workspaces (tmpdir , last_diagnostics_monkeypatch ):
96
97
DOC_SOURCE = """
97
98
def foo():
98
99
return
@@ -137,7 +138,7 @@ def test_apply_overrides():
137
138
assert plugin .apply_overrides (["1" ], ["a" , True , "b" ]) == ["a" , "1" , "b" ]
138
139
139
140
140
- def test_option_overrides (tmpdir , diag_mp , workspace ):
141
+ def test_option_overrides (tmpdir , last_diagnostics_monkeypatch , workspace ):
141
142
import sys
142
143
from textwrap import dedent
143
144
from stat import S_IRWXU
@@ -158,7 +159,7 @@ def test_option_overrides(tmpdir, diag_mp, workspace):
158
159
wrapper .chmod (S_IRWXU )
159
160
160
161
overrides = ["--python-executable" , wrapper .strpath , True ]
161
- diag_mp .setattr (
162
+ last_diagnostics_monkeypatch .setattr (
162
163
FakeConfig ,
163
164
"plugin_settings" ,
164
165
lambda _ , p : {"overrides" : overrides } if p == "pylsp_mypy" else {},
@@ -176,9 +177,9 @@ def test_option_overrides(tmpdir, diag_mp, workspace):
176
177
assert sentinel .exists ()
177
178
178
179
179
- def test_option_overrides_dmypy (diag_mp , workspace ):
180
+ def test_option_overrides_dmypy (last_diagnostics_monkeypatch , workspace ):
180
181
overrides = ["--python-executable" , "/tmp/fake" , True ]
181
- diag_mp .setattr (
182
+ last_diagnostics_monkeypatch .setattr (
182
183
FakeConfig ,
183
184
"plugin_settings" ,
184
185
lambda _ , p : {
@@ -191,7 +192,7 @@ def test_option_overrides_dmypy(diag_mp, workspace):
191
192
)
192
193
193
194
m = Mock (wraps = lambda a , ** _ : Mock (returncode = 0 , ** {"stdout.decode" : lambda : "" }))
194
- diag_mp .setattr (plugin .subprocess , "run" , m )
195
+ last_diagnostics_monkeypatch .setattr (plugin .subprocess , "run" , m )
195
196
196
197
plugin .pylsp_lint (
197
198
config = FakeConfig (),
0 commit comments