Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/test_prettier.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ class User(SQLAlchemyBase):


@pytest.mark.skipif(sys.version_info < (3, 9), reason='no indent on older versions')
@pytest.mark.skipif(sys.version_info >= (3, 13), reason='show_empty=False on newer versions')
def test_ast_expr():
assert pformat(ast.parse('print(1, 2, round(3))', mode='eval')) == (
"Expression("
Expand All @@ -503,6 +504,22 @@ def test_ast_expr():
)


@pytest.mark.skipif(sys.version_info < (3, 13), reason='no show_empty on older versions')
def test_ast_expr_show_empty():
assert pformat(ast.parse('print(1, 2, round(3))', mode='eval')) == (
"Expression("
"\n body=Call("
"\n func=Name(id='print', ctx=Load()),"
"\n args=["
"\n Constant(value=1),"
"\n Constant(value=2),"
"\n Call("
"\n func=Name(id='round', ctx=Load()),"
"\n args=["
"\n Constant(value=3)])]))"
)


@pytest.mark.skipif(sys.version_info < (3, 9), reason='no indent on older versions')
def test_ast_module():
assert pformat(ast.parse('print(1, 2, round(3))')).startswith('Module(\n body=[')
Loading