44
55import contextlib
66import os
7- import sys
87import tempfile
98
10- from test import py2_only , py3_only , IS_PY3
119from pylsp import lsp , uris
1210from pylsp .workspace import Document
1311from pylsp .plugins import pylint_lint
@@ -53,30 +51,26 @@ def test_pylint(config, workspace):
5351 assert unused_import ['severity' ] == lsp .DiagnosticSeverity .Warning
5452 assert unused_import ['tags' ] == [lsp .DiagnosticTag .Unnecessary ]
5553
56- if IS_PY3 :
57- # test running pylint in stdin
58- config .plugin_settings ('pylint' )['executable' ] = 'pylint'
59- diags = pylint_lint .pylsp_lint (config , doc , True )
54+ # test running pylint in stdin
55+ config .plugin_settings ('pylint' )['executable' ] = 'pylint'
56+ diags = pylint_lint .pylsp_lint (config , doc , True )
6057
61- msg = 'Unused import sys (unused-import)'
62- unused_import = [d for d in diags if d ['message' ] == msg ][0 ]
58+ msg = 'Unused import sys (unused-import)'
59+ unused_import = [d for d in diags if d ['message' ] == msg ][0 ]
6360
64- assert unused_import ['range' ]['start' ] == {
65- 'line' : 0 ,
66- 'character' : 0 ,
67- }
68- assert unused_import ['severity' ] == lsp .DiagnosticSeverity .Warning
61+ assert unused_import ['range' ]['start' ] == {
62+ 'line' : 0 ,
63+ 'character' : 0 ,
64+ }
65+ assert unused_import ['severity' ] == lsp .DiagnosticSeverity .Warning
6966
7067
71- @py3_only
72- def test_syntax_error_pylint_py3 (config , workspace ):
68+ def test_syntax_error_pylint (config , workspace ):
7369 with temp_document (DOC_SYNTAX_ERR , workspace ) as doc :
7470 diag = pylint_lint .pylsp_lint (config , doc , True )[0 ]
7571
76- if sys .version_info [:2 ] >= (3 , 10 ):
77- assert diag ['message' ].count ("[syntax-error] expected ':'" )
78- else :
79- assert diag ['message' ].startswith ('[syntax-error] invalid syntax' )
72+ assert diag ['message' ].startswith ("[syntax-error]" )
73+ assert diag ['message' ].count ("expected ':'" ) or diag ['message' ].count ('invalid syntax' )
8074 # Pylint doesn't give column numbers for invalid syntax.
8175 assert diag ['range' ]['start' ] == {'line' : 0 , 'character' : 12 }
8276 assert diag ['severity' ] == lsp .DiagnosticSeverity .Error
@@ -86,23 +80,12 @@ def test_syntax_error_pylint_py3(config, workspace):
8680 config .plugin_settings ('pylint' )['executable' ] = 'pylint'
8781 diag = pylint_lint .pylsp_lint (config , doc , True )[0 ]
8882
89- assert diag ['message' ].count ("expected ':'" ) or diag ['message' ].startswith ('invalid syntax' )
83+ assert diag ['message' ].count ("expected ':'" ) or diag ['message' ].count ('invalid syntax' )
9084 # Pylint doesn't give column numbers for invalid syntax.
9185 assert diag ['range' ]['start' ] == {'line' : 0 , 'character' : 12 }
9286 assert diag ['severity' ] == lsp .DiagnosticSeverity .Error
9387
9488
95- @py2_only
96- def test_syntax_error_pylint_py2 (config , workspace ):
97- with temp_document (DOC_SYNTAX_ERR , workspace ) as doc :
98- diag = pylint_lint .pylsp_lint (config , doc , True )[0 ]
99-
100- assert diag ['message' ].startswith ('[syntax-error] invalid syntax' )
101- # Pylint doesn't give column numbers for invalid syntax.
102- assert diag ['range' ]['start' ] == {'line' : 0 , 'character' : 0 }
103- assert diag ['severity' ] == lsp .DiagnosticSeverity .Error
104-
105-
10689def test_lint_free_pylint (config , workspace ):
10790 # Can't use temp_document because it might give us a file that doesn't
10891 # match pylint's naming requirements. We should be keeping this file clean
0 commit comments