summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2012-02-22 17:26:50 -0500
committerBarry Warsaw <barry@python.org>2012-02-22 17:26:50 -0500
commit8c71ce712b8dd2653906be44a483a86dfa87f0e6 (patch)
tree53f1a8a7d21dba0e5919f006819a5527da42584d
parent51857e75beb6a6ef4d53f5535f54a1a50e7f1f68 (diff)
downloadcpython-8c71ce712b8dd2653906be44a483a86dfa87f0e6.tar.gz
Back port from 2.7:
http://hg.python.org/cpython/rev/48705250232c changeset: 75187:48705250232c branch: 2.7 parent: 75184:9a1d902714ae user: Antoine Pitrou <solipsis@pitrou.net> date: Wed Feb 22 22:16:25 2012 +0100
-rw-r--r--Lib/test/test_os.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 7ad51133fe..8b667bbc5b 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -524,10 +524,12 @@ class URandomTests (unittest.TestCase):
self.assertNotEqual(data1, data2)
def get_urandom_subprocess(self, count):
+ # We need to use repr() and eval() to avoid line ending conversions
+ # under Windows.
code = '\n'.join((
'import os, sys',
'data = os.urandom(%s)' % count,
- 'sys.stdout.write(data)',
+ 'sys.stdout.write(repr(data))',
'sys.stdout.flush()',
'print >> sys.stderr, (len(data), data)'))
cmd_line = [sys.executable, '-c', code]
@@ -535,7 +537,8 @@ class URandomTests (unittest.TestCase):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
self.assertEqual(p.wait(), 0, (p.wait(), err))
- self.assertEqual(len(out), count)
+ out = eval(out)
+ self.assertEqual(len(out), count, err)
return out
def test_urandom_subprocess(self):