[py-svn] py-trunk commit d720312ad7cd: fix some py3 issues, particularly for 3.1.2 which has truncate(0) not change the file position

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Apr 28 15:24:54 CEST 2010


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <holger at merlinux.eu>
# Date 1272453725 -7200
# Node ID d720312ad7cd714d6eceb9642f5df22824ea73aa
# Parent  7cf598723a729f36167fad764a15526c7b39a780
fix some py3 issues, particularly for 3.1.2 which has truncate(0) not change the file position
so that a seek(0) is needed in addition.

--- a/py/_io/capture.py
+++ b/py/_io/capture.py
@@ -310,9 +310,11 @@ class StdCapture(Capture):
         if self._out:
             out = sys.stdout.getvalue()
             sys.stdout.truncate(0)
+            sys.stdout.seek(0)
         if self._err:
             err = sys.stderr.getvalue()
             sys.stderr.truncate(0)
+            sys.stderr.seek(0)
         return out, err 
 
 class DontReadFromInput:

--- a/py/_plugin/pytest_pytester.py
+++ b/py/_plugin/pytest_pytester.py
@@ -443,7 +443,8 @@ class LineComp:
         """
         __tracebackhide__ = True
         val = self.stringio.getvalue()
-        self.stringio.truncate(0)  # remove what we got 
+        self.stringio.truncate(0)
+        self.stringio.seek(0)
         lines1 = val.split("\n")
         return LineMatcher(lines1).fnmatch_lines(lines2)
             

--- a/py/_plugin/pytest_runner.py
+++ b/py/_plugin/pytest_runner.py
@@ -287,12 +287,13 @@ class OutcomeException(Exception):
     __str__ = __repr__
 
 class Skipped(OutcomeException): 
-    # XXX slighly hackish: on 3k we fake to live in the builtins 
+    # XXX hackish: on 3k we fake to live in the builtins 
     # in order to have Skipped exception printing shorter/nicer
     __module__ = 'builtins'
 
 class Failed(OutcomeException): 
     """ raised from an explicit call to py.test.fail() """
+    __module__ = 'builtins'
 
 class ExceptionFailure(Failed): 
     """ raised by py.test.raises on an exception-assertion mismatch. """



More information about the pytest-commit mailing list