summaryrefslogtreecommitdiff
path: root/Lib/test/test_faulthandler.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2015-01-22 17:33:28 -0800
committerGregory P. Smith <greg@krypto.org>2015-01-22 17:33:28 -0800
commita442c1f64b48e61b2c1e8f8e4cf56858f3e9221c (patch)
treeeeb16b7d979b8c0422e3540f122d93af97631ce2 /Lib/test/test_faulthandler.py
parent0b72c30fd90baca0ecfb63a0d518134e968d2415 (diff)
downloadcpython-a442c1f64b48e61b2c1e8f8e4cf56858f3e9221c.tar.gz
Only pass -E to the child interpreter if our interpreter was running in that
mode. Explicitly remove the PYTHONFAULTHANDLER environment variable before launching a child interpreter when its presence would impact the test (the reason -E was being used in the first place). This enables running the test in an environment where other Python environment variables must be set in order for things to run (such as using PYTHONHOME to tell an embedded interpreter where it should think it lives).
Diffstat (limited to 'Lib/test/test_faulthandler.py')
-rw-r--r--Lib/test/test_faulthandler.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 8dcefe41ae..e68a09e181 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -250,17 +250,25 @@ class FaultHandlerTests(unittest.TestCase):
def test_disabled_by_default(self):
# By default, the module should be disabled
code = "import faulthandler; print(faulthandler.is_enabled())"
- args = (sys.executable, '-E', '-c', code)
- # don't use assert_python_ok() because it always enable faulthandler
- output = subprocess.check_output(args)
+ args = filter(None, (sys.executable,
+ "-E" if sys.flags.ignore_environment else "",
+ "-c", code))
+ env = os.environ.copy()
+ env.pop("PYTHONFAULTHANDLER", None)
+ # don't use assert_python_ok() because it always enables faulthandler
+ output = subprocess.check_output(args, env=env)
self.assertEqual(output.rstrip(), b"False")
def test_sys_xoptions(self):
# Test python -X faulthandler
code = "import faulthandler; print(faulthandler.is_enabled())"
- args = (sys.executable, "-E", "-X", "faulthandler", "-c", code)
- # don't use assert_python_ok() because it always enable faulthandler
- output = subprocess.check_output(args)
+ args = filter(None, (sys.executable,
+ "-E" if sys.flags.ignore_environment else "",
+ "-X", "faulthandler", "-c", code))
+ env = os.environ.copy()
+ env.pop("PYTHONFAULTHANDLER", None)
+ # don't use assert_python_ok() because it always enables faulthandler
+ output = subprocess.check_output(args, env=env)
self.assertEqual(output.rstrip(), b"True")
def test_env_var(self):
@@ -269,7 +277,7 @@ class FaultHandlerTests(unittest.TestCase):
args = (sys.executable, "-c", code)
env = os.environ.copy()
env['PYTHONFAULTHANDLER'] = ''
- # don't use assert_python_ok() because it always enable faulthandler
+ # don't use assert_python_ok() because it always enables faulthandler
output = subprocess.check_output(args, env=env)
self.assertEqual(output.rstrip(), b"False")