summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/support.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index ba53ab9..64864de 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -1005,6 +1005,16 @@ def gc_collect():
gc.collect()
gc.collect()
+@contextlib.contextmanager
+def disable_gc():
+ have_gc = gc.isenabled()
+ gc.disable()
+ try:
+ yield
+ finally:
+ if have_gc:
+ gc.enable()
+
def python_is_optimized():
"""Find if Python was built with optimizations."""