File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ import ast
2
+ import sys
3
+ import pytest
4
+ from python_minifier import unparse
5
+ from python_minifier .ast_compare import compare_ast
6
+
7
+ def test_pep ():
8
+ if sys .version_info < (3 , 9 ):
9
+ pytest .skip ('Decorator expression not allowed in python <3.9' )
10
+
11
+ source = """
12
+ buttons = [QPushButton(f'Button {i}') for i in range(10)]
13
+
14
+ # Do stuff with the list of buttons...
15
+
16
+ @buttons[0].clicked.connect
17
+ def spam():
18
+ ...
19
+
20
+ @buttons[1].clicked.connect
21
+ def eggs():
22
+ ...
23
+
24
+ # Do stuff with the list of buttons...
25
+ @(f, g)
26
+ def a(): pass
27
+
28
+ @(f, g)
29
+ class A:pass
30
+
31
+ @lambda func: (lambda *p: func(*p).u())
32
+ def g(n): pass
33
+
34
+ @s := lambda func: (lambda *p: func(*p).u())
35
+ def g(name): pass
36
+
37
+ @s
38
+ def r(n, t):
39
+ pass
40
+
41
+ @lambda f: lambda *p: f or f(*p).u()
42
+ def g(name): pass
43
+
44
+ @lambda f: lambda *p: \
45
+ [_ for _ in [ \
46
+ f(*p),
47
+ ] if _][0]
48
+ def c(): pass
49
+
50
+ @lambda f: lambda *p: \
51
+ list(filter(lambda _: _,[
52
+ (a := t()) and False,
53
+ f(*p),
54
+ (b := t()) and False,
55
+ ]))[0]
56
+ def c(): pass
57
+
58
+ """
59
+
60
+ expected_ast = ast .parse (source )
61
+ actual_ast = unparse (expected_ast )
62
+ compare_ast (expected_ast , ast .parse (actual_ast ))
You can’t perform that action at this time.
0 commit comments