8
8
DOC_URI = uris .from_fs_path (__file__ )
9
9
DOC = """import sys
10
10
11
- def hello():
11
+def hello( ):
12
12
\t pass
13
13
14
14
import json
@@ -40,6 +40,14 @@ def test_pycodestyle(config):
40
40
assert mod_import ['range' ]['start' ] == {'line' : 7 , 'character' : 0 }
41
41
assert mod_import ['range' ]['end' ] == {'line' : 7 , 'character' : 1 }
42
42
43
+ msg = "E201 whitespace after '('"
44
+ mod_import = [d for d in diags if d ['message' ] == msg ][0 ]
45
+
46
+ assert mod_import ['code' ] == 'E201'
47
+ assert mod_import ['severity' ] == lsp .DiagnosticSeverity .Warning
48
+ assert mod_import ['range' ]['start' ] == {'line' : 2 , 'character' : 10 }
49
+ assert mod_import ['range' ]['end' ] == {'line' : 2 , 'character' : 14 }
50
+
43
51
44
52
def test_pycodestyle_config (workspace ):
45
53
""" Test that we load config files properly.
@@ -66,7 +74,7 @@ def test_pycodestyle_config(workspace):
66
74
assert [d for d in diags if d ['code' ] == 'W191' ]
67
75
68
76
content = {
69
- 'setup.cfg' : ('[pycodestyle]\n ignore = W191' , True ),
77
+ 'setup.cfg' : ('[pycodestyle]\n ignore = W191, E201 ' , True ),
70
78
'tox.ini' : ('' , False )
71
79
}
72
80
@@ -77,18 +85,16 @@ def test_pycodestyle_config(workspace):
77
85
78
86
# And make sure we don't get any warnings
79
87
diags = pycodestyle_lint .pyls_lint (config , doc )
80
- assert len ([d for d in diags if d ['code' ] == 'W191' ]) == 0 if working else 1
88
+ assert len ([d for d in diags if d ['code' ] == 'W191' ]) == (0 if working else 1 )
89
+ assert len ([d for d in diags if d ['code' ] == 'E201' ]) == (0 if working else 1 )
90
+ assert [d for d in diags if d ['code' ] == 'W391' ]
81
91
82
92
os .unlink (os .path .join (workspace .root_path , conf_file ))
83
93
84
94
# Make sure we can ignore via the PYLS config as well
85
- config .update ({'plugins' : {'pycodestyle' : {'ignore' : ['W191' ]}}})
95
+ config .update ({'plugins' : {'pycodestyle' : {'ignore' : ['W191' , 'E201' ]}}})
86
96
# And make sure we only get one warning
87
97
diags = pycodestyle_lint .pyls_lint (config , doc )
88
98
assert not [d for d in diags if d ['code' ] == 'W191' ]
89
-
90
- # Ignore both warnings
91
- config .update ({'plugins' : {'pycodestyle' : {'ignore' : ['W191' , 'W391' ]}}})
92
- # And make sure we get neither
93
- assert not [d for d in diags if d ['code' ] == 'W191' ]
94
- assert not [d for d in diags if d ['code' ] == 'W391' ]
99
+ assert not [d for d in diags if d ['code' ] == 'E201' ]
100
+ assert [d for d in diags if d ['code' ] == 'W391' ]
0 commit comments