[Python-checkins] cpython (merge 3.5 -> default): Issue #23981: Update test_unicodedata to use script_helpers

berker.peksag python-checkins at python.org
Wed Oct 21 20:29:16 EDT 2015


https://hg.python.org/cpython/rev/6315abbf5f71
changeset:   98822:6315abbf5f71
parent:      98820:0b09a866da77
parent:      98821:fbd83224e132
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Thu Oct 22 03:29:34 2015 +0300
summary:
  Issue #23981: Update test_unicodedata to use script_helpers

Patch by Christie.

files:
  Lib/test/test_unicodedata.py |  15 +++++----------
  1 files changed, 5 insertions(+), 10 deletions(-)


diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -9,8 +9,7 @@
 import sys
 import unittest
 import hashlib
-import subprocess
-import test.support
+from test.support import script_helper
 
 encoding = 'utf-8'
 errors = 'surrogatepass'
@@ -234,16 +233,12 @@
         code = "import sys;" \
             "sys.modules['unicodedata'] = None;" \
             """eval("'\\\\N{SOFT HYPHEN}'")"""
-        args = [sys.executable, "-c", code]
-        # We use a subprocess because the unicodedata module may already have
-        # been loaded in this process.
-        popen = subprocess.Popen(args, stderr=subprocess.PIPE)
-        popen.wait()
-        self.assertEqual(popen.returncode, 1)
+        # We use a separate process because the unicodedata module may already
+        # have been loaded in this process.
+        result = script_helper.assert_python_failure("-c", code)
         error = "SyntaxError: (unicode error) \\N escapes not supported " \
             "(can't load unicodedata module)"
-        self.assertIn(error, popen.stderr.read().decode("ascii"))
-        popen.stderr.close()
+        self.assertIn(error, result.err.decode("ascii"))
 
     def test_decimal_numeric_consistent(self):
         # Test that decimal and numeric are consistent,

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


More information about the Python-checkins mailing list