summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-07-25 17:23:53 (GMT)
committerGitHub <noreply@github.com>2018-07-25 17:23:53 (GMT)
commit60b04c9f6fb87522a62ab6b95db9f8a09aef42d4 (patch)
treeaaceeb9975ea792eb997e6c6904d5d4e23da10c8 /Lib
parent96d1e69a12ed8ab80203277e1abdaf573457a964 (diff)
downloadcpython-60b04c9f6fb87522a62ab6b95db9f8a09aef42d4.zip
cpython-60b04c9f6fb87522a62ab6b95db9f8a09aef42d4.tar.gz
cpython-60b04c9f6fb87522a62ab6b95db9f8a09aef42d4.tar.bz2
bpo-34228: Allow PYTHONTRACEMALLOC=0 (GH-8467)
PYTHONTRACEMALLOC=0 environment variable and -X tracemalloc=0 command line option are now allowed to disable explicitly tracemalloc at startup.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_tracemalloc.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py
index b0a0e1b..491cd05 100644
--- a/Lib/test/test_tracemalloc.py
+++ b/Lib/test/test_tracemalloc.py
@@ -15,6 +15,7 @@ except ImportError:
EMPTY_STRING_SIZE = sys.getsizeof(b'')
+INVALID_NFRAME = (-1, 2**30)
def get_frames(nframe, lineno_delta):
@@ -833,6 +834,13 @@ class TestCommandLine(unittest.TestCase):
stdout = stdout.rstrip()
self.assertEqual(stdout, b'False')
+ def test_env_var_disabled(self):
+ # tracing at startup
+ code = 'import tracemalloc; print(tracemalloc.is_tracing())'
+ ok, stdout, stderr = assert_python_ok('-c', code, PYTHONTRACEMALLOC='0')
+ stdout = stdout.rstrip()
+ self.assertEqual(stdout, b'False')
+
def test_env_var_enabled_at_startup(self):
# tracing at startup
code = 'import tracemalloc; print(tracemalloc.is_tracing())'
@@ -861,7 +869,7 @@ class TestCommandLine(unittest.TestCase):
def test_env_var_invalid(self):
- for nframe in (-1, 0, 2**30):
+ for nframe in INVALID_NFRAME:
with self.subTest(nframe=nframe):
self.check_env_var_invalid(nframe)
@@ -889,7 +897,7 @@ class TestCommandLine(unittest.TestCase):
self.fail(f"unexpeced output: {stderr!a}")
def test_sys_xoptions_invalid(self):
- for nframe in (-1, 0, 2**30):
+ for nframe in INVALID_NFRAME:
with self.subTest(nframe=nframe):
self.check_sys_xoptions_invalid(nframe)