summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-09-08 09:36:23 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-09-08 09:36:23 (GMT)
commit88983500767e3bd042170552c12f9f5280dd4b3a (patch)
tree8dd4b67c6e2a38e8ac5ed965aa6b1fbede657fe8 /Lib/test
parent9437d7a7fe81a5f80122d8c86ac469d20259eeea (diff)
downloadcpython-88983500767e3bd042170552c12f9f5280dd4b3a.zip
cpython-88983500767e3bd042170552c12f9f5280dd4b3a.tar.gz
cpython-88983500767e3bd042170552c12f9f5280dd4b3a.tar.bz2
Close #18957: The PYTHONFAULTHANDLER environment variable now only enables the
faulthandler module if the variable is non-empty. Same behaviour than other variables like PYTHONDONTWRITEBYTECODE.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_faulthandler.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 4a8becf..d78bcb0 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -265,17 +265,33 @@ faulthandler._sigsegv()
# By default, the module should be disabled
code = "import faulthandler; print(faulthandler.is_enabled())"
args = (sys.executable, '-E', '-c', code)
- # use subprocess module directly because test.script_helper adds
- # "-X faulthandler" to the command line
- stdout = subprocess.check_output(args)
- self.assertEqual(stdout.rstrip(), b"False")
+ # don't use assert_python_ok() because it always enable faulthandler
+ output = subprocess.check_output(args)
+ self.assertEqual(output.rstrip(), b"False")
def test_sys_xoptions(self):
# Test python -X faulthandler
code = "import faulthandler; print(faulthandler.is_enabled())"
- rc, stdout, stderr = assert_python_ok("-X", "faulthandler", "-c", code)
- stdout = (stdout + stderr).strip()
- self.assertEqual(stdout, b"True")
+ args = (sys.executable, "-E", "-X", "faulthandler", "-c", code)
+ # don't use assert_python_ok() because it always enable faulthandler
+ output = subprocess.check_output(args)
+ self.assertEqual(output.rstrip(), b"True")
+
+ def test_env_var(self):
+ # empty env var
+ code = "import faulthandler; print(faulthandler.is_enabled())"
+ args = (sys.executable, "-c", code)
+ env = os.environ.copy()
+ env['PYTHONFAULTHANDLER'] = ''
+ # don't use assert_python_ok() because it always enable faulthandler
+ output = subprocess.check_output(args, env=env)
+ self.assertEqual(output.rstrip(), b"False")
+
+ # non-empty env var
+ env = os.environ.copy()
+ env['PYTHONFAULTHANDLER'] = '1'
+ output = subprocess.check_output(args, env=env)
+ self.assertEqual(output.rstrip(), b"True")
def check_dump_traceback(self, filename):
"""