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
This commit is contained in:
holger krekel 2010-04-28 13:22:05 +02:00
parent 78d33a2f28
commit 37cdf17e0e
3 changed files with 6 additions and 2 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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. """