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

test: optimized test preformance by moving deadcode check to the end #89

Merged
merged 1 commit into from
Sep 1, 2024
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
11 changes: 7 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,11 +925,10 @@ def check_filename(self, filename, check_names):
if is_literal(node):
continue

if len(values) == 0 and is_deadcode(node):
continue

if isinstance(node,ast.Name) and node.id=="__debug__":
continue

else:
# x (is/is not) None
none_comparison = (
Expand Down Expand Up @@ -1008,8 +1007,6 @@ def check_filename(self, filename, check_names):
# "%50s"%(a,) is missing an BUILD_STRING instruction which normally maps to BinOp
continue

if len(values)==0 and is_deadcode(node):
continue

if (
isinstance(node, ast.Name)
Expand All @@ -1018,6 +1015,7 @@ def check_filename(self, filename, check_names):
):
continue


if sys.version_info >= (3, 12):
if (
isinstance(node, ast.Call)
Expand Down Expand Up @@ -1051,6 +1049,11 @@ def check_filename(self, filename, check_names):
# `not not x` is optimized to a single TO_BOOL
continue


# the deadcode check has to be the last check because it is expensive
if len(values)==0 and is_deadcode(node):
continue

if sys.version_info >= (3, 10):
correct = len(values) >= 1
elif sys.version_info >= (3, 9) and in_finally(node):
Expand Down
Loading