[Python-checkins] cpython: Make test of poll() use unbuffered IO

richard.oudkerk python-checkins at python.org
Sun Dec 9 17:10:21 CET 2012


http://hg.python.org/cpython/rev/fae25c3cff28
changeset:   80787:fae25c3cff28
user:        Richard Oudkerk <shibturn at gmail.com>
date:        Sun Dec 09 16:05:22 2012 +0000
summary:
  Make test of poll() use unbuffered IO

files:
  Lib/test/test_poll.py |  9 ++++++---
  1 files changed, 6 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -1,6 +1,6 @@
 # Test case for the os.poll() function
 
-import os, select, random, unittest
+import os, select, random, unittest, subprocess
 from test.support import TESTFN, run_unittest
 
 try:
@@ -114,7 +114,9 @@
 
     def test_poll2(self):
         cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
-        p = os.popen(cmd, 'r')
+        proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
+                                bufsize=0)
+        p = proc.stdout
         pollster = select.poll()
         pollster.register( p, select.POLLIN )
         for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10:
@@ -124,7 +126,7 @@
             fd, flags = fdlist[0]
             if flags & select.POLLHUP:
                 line = p.readline()
-                if line != "":
+                if line != b"":
                     self.fail('error: pipe seems to be closed, but still returns data')
                 continue
 
@@ -132,6 +134,7 @@
                 line = p.readline()
                 if not line:
                     break
+                self.assertEqual(line, b'testing...\n')
                 continue
             else:
                 self.fail('Unexpected return value from select.poll: %s' % fdlist)

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


More information about the Python-checkins mailing list