Fix flaky os.urandom test.

This commit is contained in:
Antoine Pitrou 2012-02-21 22:02:04 +01:00
parent 6647113419
commit 0607f731f2
1 changed files with 4 additions and 3 deletions

View File

@ -545,12 +545,13 @@ class URandomTests (unittest.TestCase):
'import os, sys',
'data = os.urandom(%s)' % count,
'sys.stdout.write(data)',
'sys.stdout.flush()'))
'sys.stdout.flush()',
'print >> sys.stderr, (len(data), data)'))
cmd_line = [sys.executable, '-c', code]
p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
out = test_support.strip_python_stderr(out)
self.assertEqual(p.wait(), 0, (p.wait(), err))
self.assertEqual(len(out), count)
return out