summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-06-22 12:05:45 (GMT)
committerGitHub <noreply@github.com>2022-06-22 12:05:45 (GMT)
commitc029b552f39200977325d4351803bdd13ddccc4f (patch)
tree984582ca4b4358dde51a1bc1fd94412cff4eafc0 /Lib/test/support/__init__.py
parentca308c13daa722f3669a14f1613da768086beb6a (diff)
downloadcpython-c029b552f39200977325d4351803bdd13ddccc4f.zip
cpython-c029b552f39200977325d4351803bdd13ddccc4f.tar.gz
cpython-c029b552f39200977325d4351803bdd13ddccc4f.tar.bz2
gh-93951: In test_bdb.StateTestCase.test_skip, avoid including auxiliary importers. (GH-93962)
Co-authored-by: Brett Cannon <brett@python.org>
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index a875548..c51a1f2 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1768,6 +1768,16 @@ def patch(test_instance, object_to_patch, attr_name, new_value):
setattr(object_to_patch, attr_name, new_value)
+@contextlib.contextmanager
+def patch_list(orig):
+ """Like unittest.mock.patch.dict, but for lists."""
+ try:
+ saved = orig[:]
+ yield
+ finally:
+ orig[:] = saved
+
+
def run_in_subinterp(code):
"""
Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc