@@ -53,7 +53,7 @@ def test_pformat_node():
53
53
54
54
55
55
def test_pformat_nested_with_offsets ():
56
- expected_38 = (
56
+ expected = (
57
57
'Assign(\n '
58
58
' lineno=1,\n '
59
59
' col_offset=0,\n '
@@ -64,15 +64,6 @@ def test_pformat_nested_with_offsets():
64
64
' type_comment=None,\n '
65
65
')'
66
66
)
67
- expected_lt38 = (
68
- 'Assign(\n '
69
- ' lineno=1,\n '
70
- ' col_offset=0,\n '
71
- " targets=[Name(lineno=1, col_offset=0, id='x', ctx=Store())],\n "
72
- ' value=Num(lineno=1, col_offset=4, n=5),\n '
73
- ')'
74
- )
75
- expected = expected_38 if sys .version_info >= (3 , 8 ) else expected_lt38
76
67
ret = astpretty .pformat (_to_module_body ('x = 5' ))
77
68
assert ret == expected
78
69
@@ -169,22 +160,7 @@ def test_pformat_nested_node_without_line_information():
169
160
' ctx=Load(),\n '
170
161
')'
171
162
)
172
- expected_lt38 = (
173
- 'Subscript(\n '
174
- ' lineno=1,\n '
175
- ' col_offset=0,\n '
176
- " value=Name(lineno=1, col_offset=0, id='a', ctx=Load()),\n "
177
- ' slice=Index(\n '
178
- ' value=Num(lineno=1, col_offset=2, n=0),\n '
179
- ' ),\n '
180
- ' ctx=Load(),\n '
181
- ')'
182
- )
183
- expected = (
184
- expected_39 if sys .version_info >= (3 , 9 ) else
185
- expected_38 if sys .version_info >= (3 , 8 ) else
186
- expected_lt38
187
- )
163
+ expected = expected_39 if sys .version_info >= (3 , 9 ) else expected_38
188
164
ret = astpretty .pformat (_to_expr_value ('a[0]' ))
189
165
assert ret == expected
190
166
@@ -201,7 +177,7 @@ def test_pprint(capsys):
201
177
202
178
203
179
def test_main_with_offsets (capsys , tmpdir ):
204
- expected_38 = '''\
180
+ expected = '''\
205
181
Module(
206
182
body=[
207
183
Assign(
@@ -217,19 +193,6 @@ def test_main_with_offsets(capsys, tmpdir):
217
193
type_ignores=[],
218
194
)
219
195
''' # noqa: E501
220
- expected_lt38 = '''\
221
- Module(
222
- body=[
223
- Assign(
224
- lineno=1,
225
- col_offset=0,
226
- targets=[Name(lineno=1, col_offset=0, id='x', ctx=Store())],
227
- value=Name(lineno=1, col_offset=4, id='y', ctx=Load()),
228
- ),
229
- ],
230
- )
231
- '''
232
- expected = expected_38 if sys .version_info >= (3 , 8 ) else expected_lt38
233
196
f = tmpdir .join ('test.py' )
234
197
f .write ('x = y\n ' )
235
198
astpretty .main ((f .strpath ,))
@@ -238,7 +201,7 @@ def test_main_with_offsets(capsys, tmpdir):
238
201
239
202
240
203
def test_main_hide_offsets (capsys , tmpdir ):
241
- expected_38 = '''\
204
+ expected = '''\
242
205
Module(
243
206
body=[
244
207
Assign(
@@ -250,29 +213,13 @@ def test_main_hide_offsets(capsys, tmpdir):
250
213
type_ignores=[],
251
214
)
252
215
'''
253
- expected_lt38 = '''\
254
- Module(
255
- body=[
256
- Assign(
257
- targets=[Name(id='x', ctx=Store())],
258
- value=Name(id='y', ctx=Load()),
259
- ),
260
- ],
261
- )
262
- '''
263
- expected = expected_38 if sys .version_info >= (3 , 8 ) else expected_lt38
264
216
f = tmpdir .join ('test.py' )
265
217
f .write ('x = y\n ' )
266
218
astpretty .main ((f .strpath , '--no-show-offsets' ))
267
219
out , _ = capsys .readouterr ()
268
220
assert out == expected
269
221
270
222
271
- def test_typedast_support ():
272
- typed = not hasattr (sys , 'pypy_version_info' )
273
- assert typed == astpretty .typed_support
274
-
275
-
276
223
TYPED_SRC = 'x = 5 # type: int\n x = "foo" # type: ignore\n '
277
224
TYPED27_OUT = '''\
278
225
Module(
@@ -354,43 +301,6 @@ def f(
354
301
'''
355
302
356
303
357
- @pytest .mark .xfail (not astpretty .typed_support , reason = 'needs typed-ast' )
358
- def test_typedast_support_27 ():
359
- expected = TYPED27_OUT .rstrip ()
360
- assert astpretty .pformat (astpretty .ast27 .parse (TYPED_SRC )) == expected
361
-
362
-
363
- @pytest .mark .xfail (not astpretty .typed_support , reason = 'needs typed-ast' )
364
- def test_typedast_support_3 ():
365
- expected = TYPED3_OUT .rstrip ()
366
- assert astpretty .pformat (astpretty .ast3 .parse (TYPED_SRC )) == expected
367
-
368
-
369
- @pytest .mark .xfail (not astpretty .typed_support , reason = 'needs typed-ast' )
370
- def test_typedast_ast27_arguments ():
371
- expected = FUNC_SRC_TYPED27_OUT .strip ()
372
- assert astpretty .pformat (astpretty .ast27 .parse (FUNC_SRC )) == expected
373
-
374
-
375
- @pytest .mark .xfail (not astpretty .typed_support , reason = 'needs typed-ast' )
376
- def test_typedast_support_cmdline_27 (tmpdir , capsys ): # pragma: no cover
377
- f = tmpdir .join ('f.py' )
378
- f .write (TYPED_SRC )
379
- assert not astpretty .main ((str (f ), '--typed-27' ))
380
- out , _ = capsys .readouterr ()
381
- assert out == TYPED27_OUT
382
-
383
-
384
- @pytest .mark .xfail (not astpretty .typed_support , reason = 'needs typed-ast' )
385
- def test_typedast_support_cmdline_3 (tmpdir , capsys ): # pragma: no cover
386
- f = tmpdir .join ('f.py' )
387
- f .write (TYPED_SRC )
388
- assert not astpretty .main ((str (f ), '--typed-3' ))
389
- out , _ = capsys .readouterr ()
390
- assert out == TYPED3_OUT
391
-
392
-
393
- @pytest .mark .xfail (sys .version_info < (3 , 8 ), reason = 'py38+ syntax only' )
394
304
def test_pformat_py38_type_comments (tmpdir , capsys ):
395
305
expected = '''\
396
306
Module(
0 commit comments