Skip to content

Commit

Permalink
reinstate diagnostics tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jul 29, 2023
1 parent 6b064bc commit d4ea5bc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion jedi_language_server/jedi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]:
until_column = (
_until_column - 1 if _until_column is not None else column + 1
)
until_line = _until_line - 1 if _until_line is not None else line + 1
until_line = _until_line - 1 if _until_line is not None else line

if (line, column) >= (until_line, until_column):
until_column, until_line = column, line
Expand Down
43 changes: 31 additions & 12 deletions tests/lsp_tests/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import copy
import json
import platform
import tempfile
from threading import Event

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


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

# wait for a second to receive all notifications
done.wait(1)
done.wait(1.1)

# Diagnostics look a little different on Windows.
filename = (
as_uri(py_file.fullpath)
if platform.system() == "Windows"
else py_file.basename
)

expected = [
{
Expand All @@ -83,17 +90,16 @@ def _handler(params):
"start": {"line": 5, "character": 15},
"end": {"line": 5, "character": 16},
},
"message": "SyntaxError: invalid syntax",
"message": f"SyntaxError: invalid syntax ({filename}, line 6)",
"severity": 1,
"source": "jedi",
"source": "compile",
}
],
}
]
assert_that(actual, is_(expected))


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

Expand Down Expand Up @@ -175,7 +181,14 @@ def _handler(params):
assert len(symbols) > 0

# wait for a second to receive all notifications
done.wait(1)
done.wait(1.1)

# Diagnostics look a little different on Windows.
filename = (
as_uri(py_file.fullpath)
if platform.system() == "Windows"
else py_file.basename
)

expected = [
{
Expand All @@ -186,17 +199,16 @@ def _handler(params):
"start": {"line": 5, "character": 15},
"end": {"line": 5, "character": 16},
},
"message": "SyntaxError: invalid syntax",
"message": f"SyntaxError: invalid syntax ({filename}, line 6)",
"severity": 1,
"source": "jedi",
"source": "compile",
}
],
}
]
assert_that(actual, is_(expected))


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

Expand Down Expand Up @@ -293,7 +305,14 @@ def _handler(params):
)

# wait for a second to receive all notifications
done.wait(1)
done.wait(1.1)

# Diagnostics look a little different on Windows.
filename = (
as_uri(py_file.fullpath)
if platform.system() == "Windows"
else py_file.basename
)

expected = [
{
Expand All @@ -304,9 +323,9 @@ def _handler(params):
"start": {"line": 5, "character": 15},
"end": {"line": 5, "character": 16},
},
"message": "SyntaxError: invalid syntax",
"message": f"SyntaxError: invalid syntax ({filename}, line 6)",
"severity": 1,
"source": "jedi",
"source": "compile",
}
],
}
Expand Down

0 comments on commit d4ea5bc

Please sign in to comment.