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

Fix tests failing in Python 3.12 #281

Merged
merged 1 commit into from
Aug 18, 2023
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
14 changes: 10 additions & 4 deletions test/test_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,23 @@ def get_visit_methods(
visitor: RefurbVisitor,
) -> Iterable[tuple[str, type[Node]]]:
"""
Find visitor methods in the instance's __dict__ (those that have been
generated in __init__) and in the class' __dict__ (the ones that are
overridden directly in the class).
Find visitor methods in the instance (those that have been generated in
__init__) and in the class' __dict__ (the ones that are overridden
directly in the class).

Not using inspect.getmembers because that goes too deep into the parents
and that would deafeat the purpose of this, which is testing that the
methods are defined in the RefurbVisitor.
"""
method_sources = itertools.chain(
visitor.__dict__.items(), visitor.__class__.__dict__.items()
[
(method_name, getattr(visitor, method_name))
for method_name in dir(visitor)
if hasattr(visitor, method_name)
],
visitor.__class__.__dict__.items(),
)

for method_name, method in method_sources:
if callable(method) and method_name.startswith("visit_"):
yield method_name, method
Expand Down