Skip to content

Commit d4ea5bc

Browse files
committed
reinstate diagnostics tests
1 parent 6b064bc commit d4ea5bc

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

jedi_language_server/jedi_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]:
308308
until_column = (
309309
_until_column - 1 if _until_column is not None else column + 1
310310
)
311-
until_line = _until_line - 1 if _until_line is not None else line + 1
311+
until_line = _until_line - 1 if _until_line is not None else line
312312

313313
if (line, column) >= (until_line, until_column):
314314
until_column, until_line = column, line

tests/lsp_tests/test_diagnostics.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import copy
44
import json
5+
import platform
56
import tempfile
67
from threading import Event
78

@@ -23,7 +24,6 @@ def get_changes(changes_file):
2324
return json.load(ch_file)
2425

2526

26-
@pytest.mark.skip(reason="Test broke with new compile-based diagnostics")
2727
def test_publish_diagnostics_on_open():
2828
"""Tests publish diagnostics on open."""
2929
content_path = DIAGNOSTICS_TEST_ROOT / "diagnostics_test1_contents.txt"
@@ -72,7 +72,14 @@ def _handler(params):
7272
assert len(symbols) > 0
7373

7474
# wait for a second to receive all notifications
75-
done.wait(1)
75+
done.wait(1.1)
76+
77+
# Diagnostics look a little different on Windows.
78+
filename = (
79+
as_uri(py_file.fullpath)
80+
if platform.system() == "Windows"
81+
else py_file.basename
82+
)
7683

7784
expected = [
7885
{
@@ -83,17 +90,16 @@ def _handler(params):
8390
"start": {"line": 5, "character": 15},
8491
"end": {"line": 5, "character": 16},
8592
},
86-
"message": "SyntaxError: invalid syntax",
93+
"message": f"SyntaxError: invalid syntax ({filename}, line 6)",
8794
"severity": 1,
88-
"source": "jedi",
95+
"source": "compile",
8996
}
9097
],
9198
}
9299
]
93100
assert_that(actual, is_(expected))
94101

95102

96-
@pytest.mark.skip(reason="Test broke with new compile-based diagnostics")
97103
def test_publish_diagnostics_on_change():
98104
"""Tests publish diagnostics on change."""
99105

@@ -175,7 +181,14 @@ def _handler(params):
175181
assert len(symbols) > 0
176182

177183
# wait for a second to receive all notifications
178-
done.wait(1)
184+
done.wait(1.1)
185+
186+
# Diagnostics look a little different on Windows.
187+
filename = (
188+
as_uri(py_file.fullpath)
189+
if platform.system() == "Windows"
190+
else py_file.basename
191+
)
179192

180193
expected = [
181194
{
@@ -186,17 +199,16 @@ def _handler(params):
186199
"start": {"line": 5, "character": 15},
187200
"end": {"line": 5, "character": 16},
188201
},
189-
"message": "SyntaxError: invalid syntax",
202+
"message": f"SyntaxError: invalid syntax ({filename}, line 6)",
190203
"severity": 1,
191-
"source": "jedi",
204+
"source": "compile",
192205
}
193206
],
194207
}
195208
]
196209
assert_that(actual, is_(expected))
197210

198211

199-
@pytest.mark.skip(reason="Test broke with new compile-based diagnostics")
200212
def test_publish_diagnostics_on_save():
201213
"""Tests publish diagnostics on save."""
202214

@@ -293,7 +305,14 @@ def _handler(params):
293305
)
294306

295307
# wait for a second to receive all notifications
296-
done.wait(1)
308+
done.wait(1.1)
309+
310+
# Diagnostics look a little different on Windows.
311+
filename = (
312+
as_uri(py_file.fullpath)
313+
if platform.system() == "Windows"
314+
else py_file.basename
315+
)
297316

298317
expected = [
299318
{
@@ -304,9 +323,9 @@ def _handler(params):
304323
"start": {"line": 5, "character": 15},
305324
"end": {"line": 5, "character": 16},
306325
},
307-
"message": "SyntaxError: invalid syntax",
326+
"message": f"SyntaxError: invalid syntax ({filename}, line 6)",
308327
"severity": 1,
309-
"source": "jedi",
328+
"source": "compile",
310329
}
311330
],
312331
}

0 commit comments

Comments
 (0)