[pypy-commit] pypy default: improve this test to also test failures on backwards seeks when no raw seek is available

bdkearns noreply at buildbot.pypy.org
Wed Feb 13 07:33:48 CET 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r61161:bca3a1371847
Date: 2013-02-13 00:41 -0500
http://bitbucket.org/pypy/pypy/changeset/bca3a1371847/

Log:	improve this test to also test failures on backwards seeks when no
	raw seek is available

diff --git a/rpython/rlib/test/test_streamio.py b/rpython/rlib/test/test_streamio.py
--- a/rpython/rlib/test/test_streamio.py
+++ b/rpython/rlib/test/test_streamio.py
@@ -390,7 +390,7 @@
         all = file.readall()
         end = len(all)
         cases = [(readto, seekto, whence) for readto in range(0, end+1)
-                                          for seekto in range(readto, end+1)
+                                          for seekto in range(0, end+1)
                                           for whence in [1, 2]]
         random.shuffle(cases)
         if isinstance(self, (LLRtypeMixin, OORtypeMixin)):
@@ -406,9 +406,19 @@
                     offset = seekto - readto
                 elif whence == 2:
                     offset = seekto - end
-                file.seek(offset, whence)
-                rest = file.readall()
-                assert rest == all[seekto:]
+                if whence == 2 and seekto < file.tell() or seekto < file.tell() - file.pos:
+                    try:
+                        file.seek(offset, whence)
+                    except streamio.MyNotImplementedError:
+                        assert whence == 1
+                    except streamio.StreamError:
+                        assert whence == 2
+                    else:
+                        assert False
+                else:
+                    file.seek(offset, whence)
+                    rest = file.readall()
+                    assert rest == all[seekto:]
             return True
         res = self.interpret(f, [])
         assert res


More information about the pypy-commit mailing list