Commits

Stefano Rivera  committed 3b966a3

Extend AppTestNonblocking to exercise limited size readlines()s, and reads that aren't multiples of the buffer-size

  • Participants
  • Parent commits 52f9fa5

Comments (0)

Files changed (1)

File pypy/module/_file/test/test_file.py

         fd_info = {}
         fd = 42
         for mode in ('r', 'rb', 'rU'):
-            for buffering in (-1, 0, 1, 2):
+            # -1, 0, 1, 2: The classes of buffering
+            # 3: Buffering that isn't a multiple of the read size
+            for buffering in (-1, 0, 1, 2, 3):
                 cls.state[fd] = 0
                 file_ = W_File(cls.space)
                 file_.file_fdopen(fd, mode, buffering)
             print all_
             assert ''.join(all_) == 'xyz\n'
 
+    def test_async_small_readline(self):
+        import errno
+        for fd in range(42, self.max_fd + 1):
+            file_ = getattr(self, 'file%i' % fd)
+            print "Fake file " + self.fd_info[fd]
+            all_ = []
+            while True:
+                try:
+                    res = file_.readline(2)
+                    if res == '':
+                        break
+                    all_.append(res)
+                except IOError, e:
+                    if e.errno == errno.EAGAIN:
+                        continue
+                    raise
+            print all_
+            assert ''.join(all_) == 'xyz\n'
+
 class AppTestConcurrency(object):
     # these tests only really make sense on top of a translated pypy-c,
     # because on top of py.py the inner calls to os.write() don't