Skip to content

Commit

Permalink
test: optimized test preformance by moving deadcode check to the end (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk authored Sep 1, 2024
1 parent 6428317 commit aa34030
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit aa34030

Please sign in to comment.