Skip to content

Commit d908ad5

Browse files
Bail out of stack traversal when hitting unittest files (#421)
As at the status quo, stack traversal terminates when hitting a file with 'pytest' or 'hammett' in the path, but blithely carries on if a file has 'unittest' in the path, despite that being the unittest framework. The simple fix to that is to also bail out if 'unittest' is in the current frame's filename.
1 parent 0232420 commit d908ad5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mutmut/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def record_trampoline_hit(name):
137137
f = inspect.currentframe()
138138
c = mutmut.config.max_stack_depth
139139
while c and f:
140-
if 'pytest' in f.f_code.co_filename or 'hammett' in f.f_code.co_filename:
140+
filename = f.f_code.co_filename
141+
if 'pytest' in filename or 'hammett' in filename or 'unittest' in filename:
141142
break
142143
f = f.f_back
143144
c -= 1

0 commit comments

Comments
 (0)