Skip to content

Commit

Permalink
- r extract variable
Browse files Browse the repository at this point in the history
Co-Authored-By: 4dsherwood <[email protected]>
Co-Authored-By: Nitsan Avni <[email protected]>
  • Loading branch information
nitsanavni and 4dsherwood committed Jan 14, 2024
1 parent 52d824f commit a98daed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions approvaltests/namer/stack_frame_namer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ def get_test_frame_index(caller: List[FrameInfo]) -> int:

@staticmethod
def is_pytest_test(frame: FrameInfo) -> bool:
method_name = frame[3]
patterns = PytestConfig.test_naming_patterns

# taken from pytest/python.py (class PyCollector)
for pattern in patterns:
if frame[3].startswith(pattern):
if method_name.startswith(pattern):
return True
# Check that name looks like a glob-string before calling fnmatch
# because this is called for every name in each collected module,
# and fnmatch is somewhat expensive to call.
elif (
"*" in pattern or "?" in pattern or "[" in pattern
) and fnmatch.fnmatch(frame[3], pattern):
) and fnmatch.fnmatch(method_name, pattern):
return True

return False
Expand Down

0 comments on commit a98daed

Please sign in to comment.