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

Add instructions to codegen test failures #582

Merged
merged 3 commits into from
Jan 5, 2022
Merged
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
25 changes: 16 additions & 9 deletions libcst/codegen/tests/test_codegen_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@


class TestCodegenClean(UnitTest):
def assert_code_matches(
self,
old_code: str,
new_code: str,
module_name: str,
) -> None:
self.assertTrue(
old_code == new_code,
f"{module_name} needs new codegen, see "
+ "`python -m libcst.codegen.generate --help` "
+ "for instructions, or run `tox -e codegen`",
)

def test_codegen_clean_visitor_functions(self) -> None:
"""
Verifies that codegen of visitor functions would not result in a
Expand Down Expand Up @@ -44,9 +57,7 @@ def test_codegen_clean_visitor_functions(self) -> None:
old_code = fp.read()

# Now that we've done simple codegen, verify that it matches.
self.assertTrue(
old_code == new_code, "libcst._typed_visitor needs new codegen!"
)
self.assert_code_matches(old_code, new_code, "libcst._typed_visitor")

def test_codegen_clean_matcher_classes(self) -> None:
"""
Expand Down Expand Up @@ -78,9 +89,7 @@ def test_codegen_clean_matcher_classes(self) -> None:
old_code = fp.read()

# Now that we've done simple codegen, verify that it matches.
self.assertTrue(
old_code == new_code, "libcst.matchers.__init__ needs new codegen!"
)
self.assert_code_matches(old_code, new_code, "libcst.matchers.__init__")

def test_codegen_clean_return_types(self) -> None:
"""
Expand Down Expand Up @@ -113,6 +122,4 @@ def test_codegen_clean_return_types(self) -> None:
old_code = fp.read()

# Now that we've done simple codegen, verify that it matches.
self.assertTrue(
old_code == new_code, "libcst.matchers._return_types needs new codegen!"
)
self.assert_code_matches(old_code, new_code, "libcst.matchers._return_types")