def is_inside_recursive_test_call():
"""Test if a function is running from a call to du.test()."""
frame = inspect.currentframe()
count_test = 0
while frame:
# Test breaking condition.
if count_test >= 1:
return True
# Find if there is a breaking condition and update the value.
test_function = frame.f_locals.get('test')
if (hasattr(test_function, '_testMethodName')) and (
test_function._testMethodName ==
'test_module_level_test_calls'):
count_test += 1
# Go to next frame.
frame = frame.f_back
return False
评论列表
文章目录