Skip to content

Fix test_ast_expr for Python 3.13 #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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