gh-119659: Move `@no_rerun` to `test.support` by sobolevn · Pull Request #119660 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 1 addition & 21 deletions Lib/test/datetimetester.py
19 changes: 19 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,25 @@ def coverage_wrapper(*args, **kwargs):
return coverage_wrapper


def no_rerun(reason):
"""Skip rerunning for a particular test.

WARNING: Use this decorator with care; skipping rerunning makes it
impossible to find reference leaks. Provide a clear reason for skipping the
test using the 'reason' parameter.
"""
def deco(func):
_has_run = False
def wrapper(self):
nonlocal _has_run
if _has_run:
self.skipTest(reason)
func(self)
_has_run = True
return wrapper
return deco


def refcount_test(test):
"""Decorator for tests which involve reference counting.

Expand Down
21 changes: 1 addition & 20 deletions Lib/test/test_import/__init__.py