-
-
Notifications
You must be signed in to change notification settings - Fork 170
/
unpacking_argument_list_comprehensions_test.py
80 lines (69 loc) · 1.8 KB
/
unpacking_argument_list_comprehensions_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pytest
from pyupgrade._data import Settings
from pyupgrade._main import _fix_plugins
@pytest.mark.parametrize(
('s', 'version'),
(
pytest.param(
'foo(*[i for i in bar])\n',
(2, 7),
id='Not Python3+',
),
pytest.param(
'2*3',
(3,),
id='Multiplication star',
),
pytest.param(
'2**3',
(3,),
id='Power star',
),
pytest.param(
'foo([i for i in bar])',
(3,),
id='List comp, no star',
),
pytest.param(
'foo(*bar)',
(3,),
id='Starred, no list comp',
),
pytest.param(
'foo(*[x async for x in bar])',
(3,),
id='async listcomp',
),
),
)
def test_fix_unpack_argument_list_comp_noop(s, version):
assert _fix_plugins(s, settings=Settings(min_version=version)) == s
@pytest.mark.parametrize(
('s', 'expected'),
(
pytest.param(
'foo(*[i for i in bar])\n',
'foo(*(i for i in bar))\n',
id='Starred list comprehension',
),
pytest.param(
'foo(\n'
' *\n'
' [i for i in bar]\n'
' )\n',
'foo(\n'
' *\n'
' (i for i in bar)\n'
' )\n',
id='Multiline starred list comprehension',
),
pytest.param(
'foo(*[i for i in bar], qux, quox=None)\n',
'foo(*(i for i in bar), qux, quox=None)\n',
id='Single line, including other args',
),
),
)
def test_fix_unpack_argument_list_comp(s, expected):
ret = _fix_plugins(s, settings=Settings((3,)))
assert ret == expected