[Python-checkins] cpython: Issue #17206: Fix test_cmd_line and test_faulthandler for my previous change

victor.stinner python-checkins at python.org
Tue Jun 25 21:54:50 CEST 2013


http://hg.python.org/cpython/rev/1a9367d5aabc
changeset:   84345:1a9367d5aabc
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jun 25 21:54:17 2013 +0200
summary:
  Issue #17206: Fix test_cmd_line and test_faulthandler for my previous change
(test.regrtest and test.script_helper enable faulthandler module in
subprocesses).

files:
  Lib/test/test_cmd_line.py     |  17 ++++++++++++-----
  Lib/test/test_faulthandler.py |   8 +++++---
  2 files changed, 17 insertions(+), 8 deletions(-)


diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -54,12 +54,19 @@
         self.assertNotIn(b'stack overflow', err)
 
     def test_xoptions(self):
-        rc, out, err = assert_python_ok('-c', 'import sys; print(sys._xoptions)')
-        opts = eval(out.splitlines()[0])
+        def get_xoptions(*args):
+            # use subprocess module directly because test.script_helper adds
+            # "-X faulthandler" to the command line
+            args = (sys.executable, '-E') + args
+            args += ('-c', 'import sys; print(sys._xoptions)')
+            out = subprocess.check_output(args)
+            opts = eval(out.splitlines()[0])
+            return opts
+
+        opts = get_xoptions()
         self.assertEqual(opts, {})
-        rc, out, err = assert_python_ok(
-            '-Xa', '-Xb=c,d=e', '-c', 'import sys; print(sys._xoptions)')
-        opts = eval(out.splitlines()[0])
+
+        opts = get_xoptions('-Xa', '-Xb=c,d=e')
         self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
 
     def test_showrefcount(self):
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -262,9 +262,11 @@
     def test_disabled_by_default(self):
         # By default, the module should be disabled
         code = "import faulthandler; print(faulthandler.is_enabled())"
-        rc, stdout, stderr = assert_python_ok("-c", code)
-        stdout = (stdout + stderr).strip()
-        self.assertEqual(stdout, b"False")
+        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")
 
     def test_sys_xoptions(self):
         # Test python -X faulthandler

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list