Skip to content
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

gh-100518: Add tests for ast.NodeTransformer #100521

Merged
merged 2 commits into from
Jan 21, 2023
Merged

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Dec 25, 2022

I've started with some very basic checks and cases, but they cover 100% of NodeTranformer.generic_visit.

CC @isidentical and @pablogsal as ast experts :)

tranformer = tranformer_class()
result_ast = ast.fix_missing_locations(tranformer.visit(initial_ast))

self.assertEqual(ast.dump(result_ast),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we have a more performant way to compare AST trees. Check out traverse_compare in test_unparse

Copy link
Member Author

@sobolevn sobolevn Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 👍
But, I had to create support.ast_helper

Copy link
Sponsor Member

@isidentical isidentical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for adding these!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants