mirror of https://github.com/python/cpython
gh-119659: Move `@no_rerun` to `test.support` (#119660)
This commit is contained in:
parent
f912e5a2f6
commit
2da0dc094f
|
@ -22,7 +22,7 @@ from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import is_resource_enabled, ALWAYS_EQ, LARGEST, SMALLEST
|
from test.support import is_resource_enabled, ALWAYS_EQ, LARGEST, SMALLEST
|
||||||
from test.support import warnings_helper
|
from test.support import warnings_helper, no_rerun
|
||||||
|
|
||||||
import datetime as datetime_module
|
import datetime as datetime_module
|
||||||
from datetime import MINYEAR, MAXYEAR
|
from datetime import MINYEAR, MAXYEAR
|
||||||
|
@ -47,26 +47,6 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
#
|
#
|
||||||
|
|
||||||
# This is copied from test_import/__init__.py.
|
|
||||||
# XXX Move it to support/__init__.py.
|
|
||||||
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
|
|
||||||
|
|
||||||
pickle_loads = {pickle.loads, pickle._loads}
|
pickle_loads = {pickle.loads, pickle._loads}
|
||||||
|
|
||||||
pickle_choices = [(pickle, pickle, proto)
|
pickle_choices = [(pickle, pickle, proto)
|
||||||
|
|
|
@ -1189,6 +1189,25 @@ def no_tracing(func):
|
||||||
return coverage_wrapper
|
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):
|
def refcount_test(test):
|
||||||
"""Decorator for tests which involve reference counting.
|
"""Decorator for tests which involve reference counting.
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ from test.support import os_helper
|
||||||
from test.support import (
|
from test.support import (
|
||||||
STDLIB_DIR, swap_attr, swap_item, cpython_only, is_apple_mobile, is_emscripten,
|
STDLIB_DIR, swap_attr, swap_item, cpython_only, is_apple_mobile, is_emscripten,
|
||||||
is_wasi, run_in_subinterp, run_in_subinterp_with_config, Py_TRACE_REFS,
|
is_wasi, run_in_subinterp, run_in_subinterp_with_config, Py_TRACE_REFS,
|
||||||
requires_gil_enabled, Py_GIL_DISABLED)
|
requires_gil_enabled, Py_GIL_DISABLED, no_rerun)
|
||||||
from test.support.import_helper import (
|
from test.support.import_helper import (
|
||||||
forget, make_legacy_pyc, unlink, unload, ready_to_import,
|
forget, make_legacy_pyc, unlink, unload, ready_to_import,
|
||||||
DirsOnSysPath, CleanImport, import_module)
|
DirsOnSysPath, CleanImport, import_module)
|
||||||
|
@ -120,25 +120,6 @@ def remove_files(name):
|
||||||
rmtree('__pycache__')
|
rmtree('__pycache__')
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
if _testsinglephase is not None:
|
if _testsinglephase is not None:
|
||||||
def restore__testsinglephase(*, _orig=_testsinglephase):
|
def restore__testsinglephase(*, _orig=_testsinglephase):
|
||||||
# We started with the module imported and want to restore
|
# We started with the module imported and want to restore
|
||||||
|
|
Loading…
Reference in New Issue