[pypy-svn] r47279 - pypy/dist/pypy/module/_file/test

arigo at codespeak.net arigo at codespeak.net
Mon Oct 8 11:58:41 CEST 2007


Author: arigo
Date: Mon Oct  8 11:58:41 2007
New Revision: 47279

Modified:
   pypy/dist/pypy/module/_file/test/test_file_extra.py
Log:
Fix an endless loop in the test if readlines() doesn't return enough data.


Modified: pypy/dist/pypy/module/_file/test/test_file_extra.py
==============================================================================
--- pypy/dist/pypy/module/_file/test/test_file_extra.py	(original)
+++ pypy/dist/pypy/module/_file/test/test_file_extra.py	Mon Oct  8 11:58:41 2007
@@ -110,12 +110,16 @@
         stop = 0
         samplelines = self.expected_lines()
         while stop < 5:
-            morelines = self.file.readlines(random.randrange(0, 300))
+            morelines = self.file.readlines(random.randrange(1, 300))
             for inputline in morelines:
                 assert inputline == samplelines[0]
                 samplelines.pop(0)
             if not samplelines:
                 stop += 1
+            else:
+                assert len(morelines) >= 1    # otherwise, this test (and
+                                              # real programs) would be prone
+                                              # to endless loops
 
     def test_seek(self):
         for i in range(100):



More information about the Pypy-commit mailing list