summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-02-22 21:16:25 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-02-22 21:16:25 (GMT)
commit341016e8bf560d00fb0cc9ad7d51a69ee3ab577c (patch)
tree7ac48b90d743a5644a5392f4845cf4c7a3c9bde3 /Lib
parentadbcc4cf403d00084c4d7e91787020a65c63d8c1 (diff)
downloadcpython-341016e8bf560d00fb0cc9ad7d51a69ee3ab577c.zip
cpython-341016e8bf560d00fb0cc9ad7d51a69ee3ab577c.tar.gz
cpython-341016e8bf560d00fb0cc9ad7d51a69ee3ab577c.tar.bz2
Fix sporadic test_os failure under Windows
Diffstat (limited to 'Lib')
-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 4898e4e..1d673f6 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -541,10 +541,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]
@@ -552,7 +554,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):