6
6
import pytest
7
7
8
8
from semshi import parser
9
- from semshi .node import (ATTRIBUTE , BUILTIN , FREE , GLOBAL , IMPORTED , LOCAL ,
9
+ from semshi .node import (ATTRIBUTE , BUILTIN , FREE , GLOBAL , IMPORTED , KEYWORD , LOCAL ,
10
10
PARAMETER , PARAMETER_UNUSED , SELF , UNRESOLVED , Node ,
11
11
group )
12
12
from semshi .parser import Parser , UnparsableError
@@ -173,7 +173,7 @@ def func2(j=k):
173
173
''' )
174
174
root = make_tree (names )
175
175
assert root ['names' ] == [
176
- 'e' , 'h' , 'func' , 'k' , 'func2' , 'func' , 'x' , 'p' , 'z'
176
+ 'e' , 'h' , 'func' , 'k' , 'func2' , 'func' , 'x' , 'y' , ' p' , 'z'
177
177
]
178
178
assert root ['listcomp' ]['names' ] == ['g' , 'g' ]
179
179
assert root ['func' ]['names' ] == ['a' , 'b' , 'c' , 'd' , 'f' , 'i' ]
@@ -189,7 +189,7 @@ def f():
189
189
a
190
190
''' )
191
191
root = make_tree (names )
192
- assert root ['names' ] == ['a' , 'A' , 'x' , 'z' ]
192
+ assert root ['names' ] == ['a' , 'A' , 'x' , 'y' , ' z' ]
193
193
194
194
195
195
def test_import_scopes_and_positions ():
@@ -483,7 +483,7 @@ async def C():
483
483
''' )
484
484
root = make_tree (names )
485
485
assert root ['names' ] == [
486
- 'd1' , 'a' , 'c' , 'A' , 'd2' , 'x' , 'z' , 'B' , 'd3' , 'C'
486
+ 'd1' , 'a' , 'b' , ' c' , 'A' , 'd2' , 'x' , 'y ' , 'z' , 'B' , 'd3' , 'C'
487
487
]
488
488
489
489
def test_global_builtin ():
@@ -827,6 +827,16 @@ def test_posonlyargs_with_annotation():
827
827
assert [n .hl_group for n in names ] == [MODULE_FUNC , UNRESOLVED , PARAMETER_UNUSED ]
828
828
829
829
830
+ def test_keyword_arguments ():
831
+ names = parse ('foo(x, y, kwarg1=z, bar=dict(value=1))' )
832
+ assert [n .name for n in names ] == [
833
+ 'foo' , 'x' , 'y' , 'kwarg1' , 'z' , 'bar' , 'dict' , 'value' ,
834
+ ]
835
+ for n in names :
836
+ if n .name == 'kwarg1' or n .name == 'value' :
837
+ assert n .hl_group == KEYWORD
838
+
839
+
830
840
@pytest .mark .skipif ('sys.version_info < (3, 8)' )
831
841
@pytest .mark .parametrize ("enable_pep563" , (False , True ))
832
842
def test_postponed_evaluation_of_annotations_pep563 (enable_pep563 ):
0 commit comments