Skip to content

Commit 1a47bf3

Browse files
committed
fix tests
1 parent 3d0cac4 commit 1a47bf3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/test_plugin.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import collections
22
import os
3+
import subprocess
4+
from pathlib import Path
5+
from typing import Dict
36
from unittest.mock import Mock
47

58
import pytest
@@ -9,7 +12,7 @@
912

1013
from pylsp_mypy import plugin
1114

12-
DOC_URI = __file__
15+
DOC_URI = f"file:/{Path(__file__)}"
1316
DOC_TYPE_ERR = """{}.append(3)
1417
"""
1518
TYPE_ERR_MSG = '"Dict[<nothing>, <nothing>]" has no attribute "append"'
@@ -18,6 +21,10 @@
1821
TEST_LINE_WITHOUT_COL = "test_plugin.py:279: " 'error: "Request" has no attribute "id"'
1922
TEST_LINE_WITHOUT_LINE = "test_plugin.py: " 'error: "Request" has no attribute "id"'
2023

24+
windows_flag: Dict[str, int] = (
25+
{"creationflags": subprocess.CREATE_NO_WINDOW} if os.name == "nt" else {} # type: ignore
26+
)
27+
2128

2229
@pytest.fixture
2330
def last_diagnostics_monkeypatch(monkeypatch):
@@ -196,10 +203,12 @@ def test_option_overrides_dmypy(last_diagnostics_monkeypatch, workspace):
196203
m = Mock(wraps=lambda a, **_: Mock(returncode=0, **{"stdout.decode": lambda: ""}))
197204
last_diagnostics_monkeypatch.setattr(plugin.subprocess, "run", m)
198205

206+
document = Document(DOC_URI, workspace, DOC_TYPE_ERR)
207+
199208
plugin.pylsp_lint(
200209
config=FakeConfig(),
201210
workspace=workspace,
202-
document=Document(DOC_URI, workspace, DOC_TYPE_ERR),
211+
document=document,
203212
is_saved=False,
204213
)
205214
expected = [
@@ -209,6 +218,6 @@ def test_option_overrides_dmypy(last_diagnostics_monkeypatch, workspace):
209218
"--python-executable",
210219
"/tmp/fake",
211220
"--show-column-numbers",
212-
__file__,
221+
document.path,
213222
]
214-
m.assert_called_with(expected, stderr=-1, stdout=-1)
223+
m.assert_called_with(expected, stderr=-1, stdout=-1, **windows_flag)

0 commit comments

Comments
 (0)