diff --git a/lexers/embedded/python.xml b/lexers/embedded/python.xml index e92867222..a6e889c64 100644 --- a/lexers/embedded/python.xml +++ b/lexers/embedded/python.xml @@ -379,7 +379,7 @@ - + diff --git a/lexers/testdata/python/test_complex_file1.expected b/lexers/testdata/python/test_complex_file1.expected index ff3592d5d..64c9f5b00 100644 --- a/lexers/testdata/python/test_complex_file1.expected +++ b/lexers/testdata/python/test_complex_file1.expected @@ -713,9 +713,7 @@ {"type":"Keyword","value":"else"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, - {"type":"NameDecorator","value":"@functools"}, - {"type":"Operator","value":"."}, - {"type":"Name","value":"wraps"}, + {"type":"NameDecorator","value":"@functools.wraps"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"func"}, {"type":"Punctuation","value":")"}, @@ -863,9 +861,7 @@ {"type":"Keyword","value":"else"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, - {"type":"NameDecorator","value":"@functools"}, - {"type":"Operator","value":"."}, - {"type":"Name","value":"wraps"}, + {"type":"NameDecorator","value":"@functools.wraps"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"func"}, {"type":"Punctuation","value":")"}, diff --git a/lexers/testdata/python/test_decorators.actual b/lexers/testdata/python/test_decorators.actual new file mode 100644 index 000000000..4b9cddc4f --- /dev/null +++ b/lexers/testdata/python/test_decorators.actual @@ -0,0 +1,15 @@ +@decorator1 +def foo(): + print("foo") + +@decorator2.member +def bar(): + print("bar") + +@decorator3 . member(param=1) +def baz(): + print("baz") + +@decorator4 . member1 .member2 (param=1) +def bat(): + print("bat") diff --git a/lexers/testdata/python/test_decorators.expected b/lexers/testdata/python/test_decorators.expected new file mode 100644 index 000000000..d03dcc361 --- /dev/null +++ b/lexers/testdata/python/test_decorators.expected @@ -0,0 +1,61 @@ +[ + {"type":"NameDecorator","value":"@decorator1"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"def"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"foo"}, + {"type":"Punctuation","value":"():"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringDouble","value":"\"foo\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n"}, + {"type":"NameDecorator","value":"@decorator2.member"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"def"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"bar"}, + {"type":"Punctuation","value":"():"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringDouble","value":"\"bar\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n"}, + {"type":"NameDecorator","value":"@decorator3 . member"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"param"}, + {"type":"Operator","value":"="}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"def"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"baz"}, + {"type":"Punctuation","value":"():"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringDouble","value":"\"baz\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n"}, + {"type":"NameDecorator","value":"@decorator4 . member1 .member2"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"param"}, + {"type":"Operator","value":"="}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"def"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"bat"}, + {"type":"Punctuation","value":"():"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringDouble","value":"\"bat\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"} +]