33import os
44import tempfile
55
6- from test import py3_only
6+ from test import py2_only , py3_only
77from pyls import lsp , uris
88from pyls .workspace import Document
99from 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+
6475def 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