4
4
5
5
import contextlib
6
6
import os
7
- import sys
8
7
import tempfile
9
8
10
- from test import py2_only , py3_only , IS_PY3
11
9
from pylsp import lsp , uris
12
10
from pylsp .workspace import Document
13
11
from pylsp .plugins import pylint_lint
@@ -53,30 +51,26 @@ def test_pylint(config, workspace):
53
51
assert unused_import ['severity' ] == lsp .DiagnosticSeverity .Warning
54
52
assert unused_import ['tags' ] == [lsp .DiagnosticTag .Unnecessary ]
55
53
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 )
60
57
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 ]
63
60
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
69
66
70
67
71
- @py3_only
72
- def test_syntax_error_pylint_py3 (config , workspace ):
68
+ def test_syntax_error_pylint (config , workspace ):
73
69
with temp_document (DOC_SYNTAX_ERR , workspace ) as doc :
74
70
diag = pylint_lint .pylsp_lint (config , doc , True )[0 ]
75
71
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' )
80
74
# Pylint doesn't give column numbers for invalid syntax.
81
75
assert diag ['range' ]['start' ] == {'line' : 0 , 'character' : 12 }
82
76
assert diag ['severity' ] == lsp .DiagnosticSeverity .Error
@@ -86,23 +80,12 @@ def test_syntax_error_pylint_py3(config, workspace):
86
80
config .plugin_settings ('pylint' )['executable' ] = 'pylint'
87
81
diag = pylint_lint .pylsp_lint (config , doc , True )[0 ]
88
82
89
- assert diag ['message' ].count ("expected ':'" ) or diag ['message' ].startswith ('invalid syntax' )
83
+ assert diag ['message' ].count ("expected ':'" ) or diag ['message' ].count ('invalid syntax' )
90
84
# Pylint doesn't give column numbers for invalid syntax.
91
85
assert diag ['range' ]['start' ] == {'line' : 0 , 'character' : 12 }
92
86
assert diag ['severity' ] == lsp .DiagnosticSeverity .Error
93
87
94
88
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
-
106
89
def test_lint_free_pylint (config , workspace ):
107
90
# Can't use temp_document because it might give us a file that doesn't
108
91
# match pylint's naming requirements. We should be keeping this file clean
0 commit comments