Skip to content

Commit 6b35a2f

Browse files
committed
adding a different test for python2
1 parent 7048c35 commit 6b35a2f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
unix_only = pytest.mark.skipif(IS_WIN, reason="Unix only")
99
windows_only = pytest.mark.skipif(not IS_WIN, reason="Windows only")
1010
py3_only = pytest.mark.skipif(not IS_PY3, reason="Python3 only")
11+
py2_only = pytest.mark.skipif(IS_PY3, reason="Python2 only")

test/plugins/test_pylint_lint.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import tempfile
55

6-
from test import py3_only
6+
from test import py2_only, py3_only
77
from pyls import lsp, uris
88
from pyls.workspace import Document
99
from pyls.plugins import pylint_lint
@@ -51,7 +51,7 @@ def test_pylint(config):
5151

5252

5353
@py3_only
54-
def test_syntax_error_pylint(config):
54+
def test_syntax_error_pylint_py3(config):
5555
with temp_document(DOC_SYNTAX_ERR) as doc:
5656
diag = pylint_lint.pyls_lint(config, doc, True)[0]
5757

@@ -61,6 +61,17 @@ def test_syntax_error_pylint(config):
6161
assert diag['severity'] == lsp.DiagnosticSeverity.Error
6262

6363

64+
@py2_only
65+
def test_syntax_error_pylint_py2(config):
66+
with temp_document(DOC_SYNTAX_ERR) as doc:
67+
diag = pylint_lint.pyls_lint(config, doc, True)[0]
68+
69+
assert diag['message'].startswith('[syntax-error] invalid syntax')
70+
# Pylint doesn't give column numbers for invalid syntax.
71+
assert diag['range']['start'] == {'line': 0, 'character': 0}
72+
assert diag['severity'] == lsp.DiagnosticSeverity.Error
73+
74+
6475
def test_lint_free_pylint(config):
6576
# Can't use temp_document because it might give us a file that doesn't
6677
# match pylint's naming requirements. We should be keeping this file clean

0 commit comments

Comments
 (0)