summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-15 23:18:55 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-15 23:18:55 (GMT)
commitc9e363c2eb3eed920bcd0d08a2eabdfa939b1270 (patch)
treedcccf25bf9c8e8dcd31dca35bb77d4d95f4e5d56 /Lib/test/test_subprocess.py
parentaf2362a584c01dec32d7f1a23d3e6f653f11dde4 (diff)
downloadcpython-c9e363c2eb3eed920bcd0d08a2eabdfa939b1270.zip
cpython-c9e363c2eb3eed920bcd0d08a2eabdfa939b1270.tar.gz
cpython-c9e363c2eb3eed920bcd0d08a2eabdfa939b1270.tar.bz2
Make test_subprocess pass. The subprocess module now reads and writes
bytes instead of strings. We'll see how long that lasts.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py29
1 files changed, 8 insertions, 21 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index ce7b659..f87fc91 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -24,7 +24,7 @@ else:
# shutdown time. That frustrates tests trying to check stderr produced
# from a spawned Python process.
def remove_stderr_debug_decorations(stderr):
- return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
+ return re.sub(r"\[\d+ refs\]\r?\n?$", "", str8(stderr))
class ProcessTestCase(unittest.TestCase):
def setUp(self):
@@ -162,7 +162,7 @@ class ProcessTestCase(unittest.TestCase):
stdout=d)
p.wait()
os.lseek(d, 0, 0)
- self.assertEqual(os.read(d, 1024), "orange")
+ self.assertEqual(os.read(d, 1024), b"orange")
def test_stdout_fileobj(self):
# stdout is set to open file object
@@ -300,7 +300,7 @@ class ProcessTestCase(unittest.TestCase):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate("banana")
- self.assertEqual(stdout, "banana")
+ self.assertEqual(stdout, b"banana")
self.assertEqual(remove_stderr_debug_decorations(stderr),
"pineapple")
@@ -331,7 +331,7 @@ class ProcessTestCase(unittest.TestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- string_to_write = "abc"*pipe_buf
+ string_to_write = b"abc"*pipe_buf
(stdout, stderr) = p.communicate(string_to_write)
self.assertEqual(stdout, string_to_write)
@@ -345,7 +345,7 @@ class ProcessTestCase(unittest.TestCase):
stderr=subprocess.PIPE)
p.stdin.write("banana")
(stdout, stderr) = p.communicate("split")
- self.assertEqual(stdout, "bananasplit")
+ self.assertEqual(stdout, b"bananasplit")
self.assertEqual(remove_stderr_debug_decorations(stderr), "")
def test_universal_newlines(self):
@@ -365,14 +365,7 @@ class ProcessTestCase(unittest.TestCase):
stdout=subprocess.PIPE,
universal_newlines=1)
stdout = p.stdout.read()
- if hasattr(file, 'newlines'):
- # Interpreter with universal newline support
- self.assertEqual(stdout,
- "line1\nline2\nline3\nline4\nline5\nline6")
- else:
- # Interpreter without universal newline support
- self.assertEqual(stdout,
- "line1\nline2\rline3\r\nline4\r\nline5\nline6")
+ self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6")
def test_universal_newlines_communicate(self):
# universal newlines through communicate()
@@ -392,13 +385,7 @@ class ProcessTestCase(unittest.TestCase):
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=1)
(stdout, stderr) = p.communicate()
- if hasattr(file, 'newlines'):
- # Interpreter with universal newline support
- self.assertEqual(stdout,
- "line1\nline2\nline3\nline4\nline5\nline6")
- else:
- # Interpreter without universal newline support
- self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6")
+ self.assertEqual(stdout, b"line1\nline2\nline3\nline4\nline5\nline6")
def test_no_leaking(self):
# Make sure we leak no resources
@@ -414,7 +401,7 @@ class ProcessTestCase(unittest.TestCase):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
data = p.communicate("lime")[0]
- self.assertEqual(data, "lime")
+ self.assertEqual(data, b"lime")
def test_list2cmdline(self):