[Piglit] [PATCH 32/44] log_tests.py: fix incompatible seek for python 3

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Wed Jan 27 16:06:40 PST 2016


From: Dylan Baker <baker.dylan.c at gmail.com>

In python2 one can seek to negatives (-1 is the end of the file, for
example). In python 2.6+ (and exclusively in python 3) one instead uses
the second argument of seek to say whether to start at the start or end
of the file, and then an exact point. So file.seek(-1) -> file.seek(0,
2)

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 unittests/log_tests.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unittests/log_tests.py b/unittests/log_tests.py
index 63aae5e..8a90a21 100644
--- a/unittests/log_tests.py
+++ b/unittests/log_tests.py
@@ -139,7 +139,7 @@ def check_no_output(func, args, file_=sys.stdout):
     file_.truncate()
 
     func(*args)
-    file_.seek(-1)
+    file_.seek(0, 2)
     nt.eq_(file_.tell(), 0,
            msg='file.tell() is at {}, but should be at 0'.format(file_.tell()))
 
-- 
2.7.0



More information about the Piglit mailing list