[Python-checkins] cpython (merge 3.2 -> default): (merge 3.2) Issue #12383: fix test_empty_env() of subprocess on Mac OS X

victor.stinner python-checkins at python.org
Wed Jun 22 21:29:03 CEST 2011


http://hg.python.org/cpython/rev/29819072855a
changeset:   70927:29819072855a
parent:      70925:5a2602939d5d
parent:      70926:da3af4b131d7
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Wed Jun 22 21:29:07 2011 +0200
summary:
  (merge 3.2) Issue #12383: fix test_empty_env() of subprocess on Mac OS X

Mac OS X adds __CF_USER_TEXT_ENCODING variable to an empty environment. Fix
also the test on the Py_ENABLE_SHARED config varible: test that the variable is
present, don't check it's value.

files:
  Lib/test/test_subprocess.py |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -390,7 +390,7 @@
             stdout, stderr = p.communicate()
             self.assertEqual(stdout, b"orange")
 
-    @unittest.skipIf(sysconfig.get_config_var('Py_ENABLE_SHARED') == 1,
+    @unittest.skipIf(sysconfig.get_config_var('Py_ENABLE_SHARED') is not None,
                      'the python library cannot be loaded '
                      'with an empty environment')
     def test_empty_env(self):
@@ -400,7 +400,11 @@
                               stdout=subprocess.PIPE,
                               env={}) as p:
             stdout, stderr = p.communicate()
-            self.assertEqual(stdout.strip(), b"[]")
+            self.assertIn(stdout.strip(),
+                (b"[]",
+                 # Mac OS X adds __CF_USER_TEXT_ENCODING variable to an empty
+                 # environment
+                 b"['__CF_USER_TEXT_ENCODING']"))
 
     def test_communicate_stdin(self):
         p = subprocess.Popen([sys.executable, "-c",

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


More information about the Python-checkins mailing list