From 37cdf17e0e568aed4d27cfb207cf0efc89631779 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 28 Apr 2010 13:22:05 +0200 Subject: [PATCH] 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. --HG-- branch : trunk --- py/_io/capture.py | 2 ++ py/_plugin/pytest_pytester.py | 3 ++- py/_plugin/pytest_runner.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/py/_io/capture.py b/py/_io/capture.py index 5daf43c6d..093685e82 100644 --- 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: diff --git a/py/_plugin/pytest_pytester.py b/py/_plugin/pytest_pytester.py index a87d4c574..ea6c85791 100644 --- 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) diff --git a/py/_plugin/pytest_runner.py b/py/_plugin/pytest_runner.py index c295dbe5f..005fa5c0b 100644 --- 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. """