diff options
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r-- | Lib/test/support/__init__.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 63435780c9..9afa282b69 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1681,6 +1681,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 |