diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-11-23 11:27:24 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-11-23 11:27:24 (GMT) |
commit | ed3b0bca3ef9d7bdbb8bd8e67e60e85f5a336da0 (patch) | |
tree | fd4390855d293372f73048fdf4b3e6b4a7cdf440 /Lib/test/support | |
parent | 0fb6072fad411eba171b53037bcc04d07c7b0770 (diff) | |
download | cpython-ed3b0bca3ef9d7bdbb8bd8e67e60e85f5a336da0.zip cpython-ed3b0bca3ef9d7bdbb8bd8e67e60e85f5a336da0.tar.gz cpython-ed3b0bca3ef9d7bdbb8bd8e67e60e85f5a336da0.tar.bz2 |
Issue #18874: Implement the PEP 454 (tracemalloc)
Diffstat (limited to 'Lib/test/support')
-rw-r--r-- | Lib/test/support/__init__.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 87c039a..a242a47 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2154,3 +2154,22 @@ def patch(test_instance, object_to_patch, attr_name, new_value): # actually override the attribute setattr(object_to_patch, attr_name, new_value) + + +def run_in_subinterp(code): + """ + Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc + module is enabled. + """ + # Issue #10915, #15751: PyGILState_*() functions don't work with + # sub-interpreters, the tracemalloc module uses these functions internally + try: + import tracemalloc + except ImportError: + pass + else: + if tracemalloc.is_tracing(): + raise unittest.SkipTest("run_in_subinterp() cannot be used " + "if tracemalloc module is tracing " + "memory allocations") + return _testcapi.run_in_subinterp(code) |