[py-svn] r37741 - in py/trunk/py: . doc io io/test log/testing misc misc/testing test test/rsession test/rsession/testing test/testing thread/testing
hpk at codespeak.net
hpk at codespeak.net
Thu Feb 1 16:20:45 CET 2007
Author: hpk
Date: Thu Feb 1 16:20:39 2007
New Revision: 37741
Added:
py/trunk/py/doc/io.txt (contents, props changed)
py/trunk/py/io/fdcapture.py
- copied, changed from r37733, py/trunk/py/io/capture.py
py/trunk/py/io/stdcapture.py
- copied, changed from r37733, py/trunk/py/io/capture.py
py/trunk/py/io/test/test_simplecapture.py
- copied, changed from r37733, py/trunk/py/misc/testing/test_simplecapture.py
Removed:
py/trunk/py/io/capture.py
py/trunk/py/misc/capture.py
py/trunk/py/misc/simplecapture.py
py/trunk/py/misc/testing/test_simplecapture.py
py/trunk/py/test/todo-cleanup.txt
Modified:
py/trunk/py/__init__.py
py/trunk/py/doc/TODO.txt
py/trunk/py/doc/index.txt
py/trunk/py/io/test/test_capture.py
py/trunk/py/log/testing/test_log.py
py/trunk/py/test/collect.py
py/trunk/py/test/item.py
py/trunk/py/test/rsession/local.py
py/trunk/py/test/rsession/rsession.py
py/trunk/py/test/rsession/testing/test_reporter.py
py/trunk/py/test/testing/test_session.py
py/trunk/py/thread/testing/test_pool.py
Log:
monster checking for
* unifying IO capturing methods
* py.io.StdCapture and py.io.StdCaptureFD
(and both have a classmethod 'call' that is
a shortcut for capturing output while
executing a function)
* removing lots of duplicate code
* providing some examples in py/doc/io.txt
at least tests on win32 and linux seem
to pass all for me.
Modified: py/trunk/py/__init__.py
==============================================================================
--- py/trunk/py/__init__.py (original)
+++ py/trunk/py/__init__.py Thu Feb 1 16:20:39 2007
@@ -16,7 +16,7 @@
download_url = "http://codespeak.net/download/py/%s.tar.gz" %(version,),
license = "MIT license",
platforms = ['unix', 'linux', 'cygwin'],
- author = "holger krekel & others",
+ author = "holger krekel, Armin Rigo, Guido Wesdorp, Maciej Fijalkowski & others",
author_email = "py-dev at codespeak.net",
long_description = globals()['__doc__'],
@@ -94,9 +94,9 @@
# input-output helping
'io.dupfile' : ('./io/dupfile.py', 'dupfile'),
- 'io.FDCapture' : ('./io/capture.py', 'FDCapture'),
- 'io.OutErrCapture' : ('./io/capture.py', 'OutErrCapture'),
- 'io.callcapture' : ('./io/capture.py', 'callcapture'),
+ 'io.FDCapture' : ('./io/fdcapture.py', 'FDCapture'),
+ 'io.StdCapture' : ('./io/stdcapture.py', 'StdCapture'),
+ 'io.StdCaptureFD' : ('./io/stdcapture.py', 'StdCaptureFD'),
# error module, defining all errno's as Classes
'error' : ('./misc/error.py', 'error'),
Modified: py/trunk/py/doc/TODO.txt
==============================================================================
--- py/trunk/py/doc/TODO.txt (original)
+++ py/trunk/py/doc/TODO.txt Thu Feb 1 16:20:39 2007
@@ -97,7 +97,7 @@
os.fork to work))
* see why startcapture() used to not use FD-based
- "py.io.OutErrCapture" to isolate standard output.
+ "py.io.StdCaptureFD" to isolate standard output.
use that check if all py and PyPy tests pass
as good as they do without.
Modified: py/trunk/py/doc/index.txt
==============================================================================
--- py/trunk/py/doc/index.txt (original)
+++ py/trunk/py/doc/index.txt Thu Feb 1 16:20:39 2007
@@ -11,7 +11,9 @@
`py.code`_: High-level access/manipulation of Python code and traceback objects.
-`py.xml`_ a fast'n'easy way to generate xml/html documents (including CSS-styling)
+`py.xml`_ for generating in-memory xml/html object trees
+
+`py.io`_ Helper Classes for Capturing of Input/Output
`py.log`_ an alpha document about the ad-hoc logging facilities
Added: py/trunk/py/doc/io.txt
==============================================================================
--- (empty file)
+++ py/trunk/py/doc/io.txt Thu Feb 1 16:20:39 2007
@@ -0,0 +1,45 @@
+=======
+py.io
+=======
+
+.. contents::
+.. sectnum::
+
+The 'py' lib provides helper classes for capturing IO during
+execution of a program.
+
+IO Capturing examples
+===============================================
+
+:api:`py.io.StdCapture`
+---------------------------
+
+Basic Example:
+
+ >>> import py
+ >>> capture = py.io.StdCapture()
+ >>> print "hello"
+ >>> out,err = capture.reset()
+ >>> out.strip() == "hello"
+ True
+
+For calling functions you may use a shortcut:
+ >>> import py
+ >>> def f(): print "hello"
+ >>> res, out, err = py.io.StdCapture.call(f)
+ >>> out.strip() == "hello"
+ True
+
+:api:`py.io.StdCaptureFD`
+---------------------------
+
+If you also want to capture writes to the stdout/stdin
+filedescriptors you may invoke:
+
+ >>> import py, sys
+ >>> capture = py.io.StdCaptureFD()
+ >>> sys.stdout.write("hello")
+ >>> sys.stderr.write("world")
+ >>> out,err = capture.reset()
+ >>> out.strip() + err.strip() == "helloworld"
+ True
Deleted: /py/trunk/py/io/capture.py
==============================================================================
--- /py/trunk/py/io/capture.py Thu Feb 1 16:20:39 2007
+++ (empty file)
@@ -1,101 +0,0 @@
-
-import os
-import sys
-import thread
-import py
-
-class FDCapture:
- """ Capture IO to/from a given os-level filedescriptor. """
-
- def __init__(self, targetfd, tmpfile=None):
- self.targetfd = targetfd
- if tmpfile is None:
- tmpfile = self.maketmpfile()
- self.tmpfile = tmpfile
- self._savefd = os.dup(targetfd)
- os.dup2(self.tmpfile.fileno(), targetfd)
- self._patched = []
-
- def setasfile(self, name, module=sys):
- """ patch <module>.<name> to self.tmpfile
- """
- key = (module, name)
- self._patched.append((key, getattr(module, name)))
- setattr(module, name, self.tmpfile)
-
- def unsetfiles(self):
- """ unpatch all patched items
- """
- while self._patched:
- (module, name), value = self._patched.pop()
- setattr(module, name, value)
-
- def done(self):
- """ unpatch and clean up, returns the self.tmpfile (file object)
- """
- os.dup2(self._savefd, self.targetfd)
- self.unsetfiles()
- os.close(self._savefd)
- self.tmpfile.seek(0)
- return self.tmpfile
-
- def maketmpfile(self):
- """ create a temporary file
- """
- f = os.tmpfile()
- newf = py.io.dupfile(f)
- f.close()
- return newf
-
- def writeorg(self, str):
- """ write a string to the original file descriptor
- """
- tempfp = os.tmpfile()
- try:
- os.dup2(self._savefd, tempfp.fileno())
- tempfp.write(str)
- finally:
- tempfp.close()
-
-class OutErrCapture:
- """ capture Stdout and Stderr both on filedescriptor
- and sys.stdout/stderr level.
- """
- def __init__(self, out=True, err=True, patchsys=True):
- if out:
- self.out = FDCapture(1)
- if patchsys:
- self.out.setasfile('stdout')
- if err:
- self.err = FDCapture(2)
- if patchsys:
- self.err.setasfile('stderr')
-
- def reset(self):
- """ reset sys.stdout and sys.stderr
-
- returns a tuple of file objects (out, err) for the captured
- data
- """
- out = err = ""
- if hasattr(self, 'out'):
- outfile = self.out.done()
- out = outfile.read()
- if hasattr(self, 'err'):
- errfile = self.err.done()
- err = errfile.read()
- return out, err
-
-def callcapture(func, *args, **kwargs):
- """ call the given function with args/kwargs
- and return a (res, out, err) tuple where
- out and err represent the output/error output
- during function execution.
- """
- so = OutErrCapture()
- try:
- res = func(*args, **kwargs)
- finally:
- out, err = so.reset()
- return res, out, err
-
Copied: py/trunk/py/io/fdcapture.py (from r37733, py/trunk/py/io/capture.py)
==============================================================================
--- py/trunk/py/io/capture.py (original)
+++ py/trunk/py/io/fdcapture.py Thu Feb 1 16:20:39 2007
@@ -57,45 +57,3 @@
finally:
tempfp.close()
-class OutErrCapture:
- """ capture Stdout and Stderr both on filedescriptor
- and sys.stdout/stderr level.
- """
- def __init__(self, out=True, err=True, patchsys=True):
- if out:
- self.out = FDCapture(1)
- if patchsys:
- self.out.setasfile('stdout')
- if err:
- self.err = FDCapture(2)
- if patchsys:
- self.err.setasfile('stderr')
-
- def reset(self):
- """ reset sys.stdout and sys.stderr
-
- returns a tuple of file objects (out, err) for the captured
- data
- """
- out = err = ""
- if hasattr(self, 'out'):
- outfile = self.out.done()
- out = outfile.read()
- if hasattr(self, 'err'):
- errfile = self.err.done()
- err = errfile.read()
- return out, err
-
-def callcapture(func, *args, **kwargs):
- """ call the given function with args/kwargs
- and return a (res, out, err) tuple where
- out and err represent the output/error output
- during function execution.
- """
- so = OutErrCapture()
- try:
- res = func(*args, **kwargs)
- finally:
- out, err = so.reset()
- return res, out, err
-
Copied: py/trunk/py/io/stdcapture.py (from r37733, py/trunk/py/io/capture.py)
==============================================================================
--- py/trunk/py/io/capture.py (original)
+++ py/trunk/py/io/stdcapture.py Thu Feb 1 16:20:39 2007
@@ -1,73 +1,36 @@
-
import os
import sys
-import thread
import py
+try: from cStringIO import StringIO
+except ImportError: from StringIO import StringIO
-class FDCapture:
- """ Capture IO to/from a given os-level filedescriptor. """
-
- def __init__(self, targetfd, tmpfile=None):
- self.targetfd = targetfd
- if tmpfile is None:
- tmpfile = self.maketmpfile()
- self.tmpfile = tmpfile
- self._savefd = os.dup(targetfd)
- os.dup2(self.tmpfile.fileno(), targetfd)
- self._patched = []
-
- def setasfile(self, name, module=sys):
- """ patch <module>.<name> to self.tmpfile
- """
- key = (module, name)
- self._patched.append((key, getattr(module, name)))
- setattr(module, name, self.tmpfile)
-
- def unsetfiles(self):
- """ unpatch all patched items
- """
- while self._patched:
- (module, name), value = self._patched.pop()
- setattr(module, name, value)
-
- def done(self):
- """ unpatch and clean up, returns the self.tmpfile (file object)
- """
- os.dup2(self._savefd, self.targetfd)
- self.unsetfiles()
- os.close(self._savefd)
- self.tmpfile.seek(0)
- return self.tmpfile
-
- def maketmpfile(self):
- """ create a temporary file
- """
- f = os.tmpfile()
- newf = py.io.dupfile(f)
- f.close()
- return newf
-
- def writeorg(self, str):
- """ write a string to the original file descriptor
- """
- tempfp = os.tmpfile()
- try:
- os.dup2(self._savefd, tempfp.fileno())
- tempfp.write(str)
- finally:
- tempfp.close()
+class Capture(object):
+ def call(cls, func, *args, **kwargs):
+ """ return a (res, out, err) tuple where
+ out and err represent the output/error output
+ during function execution.
+ call the given function with args/kwargs
+ and capture output/error during its execution.
+ """
+ so = cls()
+ try:
+ res = func(*args, **kwargs)
+ finally:
+ out, err = so.reset()
+ return res, out, err
+ call = classmethod(call)
-class OutErrCapture:
+class StdCaptureFD(Capture):
""" capture Stdout and Stderr both on filedescriptor
and sys.stdout/stderr level.
"""
def __init__(self, out=True, err=True, patchsys=True):
if out:
- self.out = FDCapture(1)
+ self.out = py.io.FDCapture(1)
if patchsys:
self.out.setasfile('stdout')
if err:
- self.err = FDCapture(2)
+ self.err = py.io.FDCapture(2)
if patchsys:
self.err.setasfile('stderr')
@@ -86,16 +49,44 @@
err = errfile.read()
return out, err
-def callcapture(func, *args, **kwargs):
- """ call the given function with args/kwargs
- and return a (res, out, err) tuple where
- out and err represent the output/error output
- during function execution.
- """
- so = OutErrCapture()
- try:
- res = func(*args, **kwargs)
- finally:
- out, err = so.reset()
- return res, out, err
+class StdCapture(Capture):
+ """ capture sys.stdout/sys.stderr (but not system level fd 1 and 2).
+ this captures only "In-Memory" and is currently intended to be
+ used by the unittest package to capture print-statements in tests.
+ """
+ def __init__(self):
+ self.oldin = sys.stdin
+ self.oldout = sys.stdout
+ self.olderr = sys.stderr
+ sys.stdin = self.newin = DontReadFromInput()
+ sys.stdout = self.newout = StringIO()
+ sys.stderr = self.newerr = StringIO()
+
+ def reset(self):
+ """ return captured output and restore sys.stdout/err."""
+ x, y = self.done()
+ return x.read(), y.read()
+
+ def done(self):
+ o,e = sys.stdout, sys.stderr
+ sys.stdin, sys.stdout, sys.stderr = (
+ self.oldin, self.oldout, self.olderr)
+ del self.oldin, self.oldout, self.olderr
+ o, e = self.newout, self.newerr
+ o.seek(0)
+ e.seek(0)
+ return o,e
+
+class DontReadFromInput:
+ """Temporary stub class. Ideally when stdin is accessed, the
+ capturing should be turned off, with possibly all data captured
+ so far sent to the screen. This should be configurable, though,
+ because in automated test runs it is better to crash than
+ hang indefinitely.
+ """
+ def read(self, *args):
+ raise IOError("reading from stdin while output is captured")
+ readline = read
+ readlines = read
+ __iter__ = read
Modified: py/trunk/py/io/test/test_capture.py
==============================================================================
--- py/trunk/py/io/test/test_capture.py (original)
+++ py/trunk/py/io/test/test_capture.py Thu Feb 1 16:20:39 2007
@@ -59,7 +59,7 @@
class TestCapturing:
def getcapture(self):
- return py.io.OutErrCapture()
+ return py.io.StdCaptureFD()
def test_capturing_simple(self):
cap = self.getcapture()
@@ -120,13 +120,13 @@
print >>py.std.sys.stderr, y
return 42
- res, out, err = py.io.callcapture(func, 3, y=4)
+ res, out, err = py.io.StdCaptureFD.call(func, 3, y=4)
assert res == 42
assert out.startswith("3")
assert err.startswith("4")
def test_just_out_capture():
- cap = py.io.OutErrCapture(out=True, err=False)
+ cap = py.io.StdCaptureFD(out=True, err=False)
print >>sys.stdout, "hello"
print >>sys.stderr, "world"
out, err = cap.reset()
@@ -134,7 +134,7 @@
assert not err
def test_just_err_capture():
- cap = py.io.OutErrCapture(out=False, err=True)
+ cap = py.io.StdCaptureFD(out=False, err=True)
print >>sys.stdout, "hello"
print >>sys.stderr, "world"
out, err = cap.reset()
@@ -142,7 +142,7 @@
assert not out
def test_capture_no_sys():
- cap = py.io.OutErrCapture(patchsys=False)
+ cap = py.io.StdCaptureFD(patchsys=False)
print >>sys.stdout, "hello"
print >>sys.stderr, "world"
os.write(1, "1")
Copied: py/trunk/py/io/test/test_simplecapture.py (from r37733, py/trunk/py/misc/testing/test_simplecapture.py)
==============================================================================
--- py/trunk/py/misc/testing/test_simplecapture.py (original)
+++ py/trunk/py/io/test/test_simplecapture.py Thu Feb 1 16:20:39 2007
@@ -1,29 +1,10 @@
import os, sys
import py
-from py.__.misc.simplecapture import SimpleOutErrCapture, callcapture
-from py.__.misc.capture import Capture, FDCapture
-
-class TestFDCapture:
- def test_basic(self):
- tmpfile = py.std.os.tmpfile()
- fd = tmpfile.fileno()
- cap = FDCapture(fd)
- os.write(fd, "hello")
- f = cap.done()
- s = f.read()
- assert s == "hello"
-
- def test_stderr(self):
- cap = FDCapture(2, 'stderr')
- print >>sys.stderr, "hello"
- f = cap.done()
- s = f.read()
- assert s == "hello\n"
class TestCapturingOnSys:
def getcapture(self):
- return SimpleOutErrCapture()
+ return py.io.StdCapture()
def test_capturing_simple(self):
cap = self.getcapture()
@@ -73,20 +54,14 @@
finally:
cap.reset()
-def test_callcapture():
+def test_callcapture_nofd():
def func(x, y):
print x
print >>py.std.sys.stderr, y
return 42
- res, out, err = callcapture(func, 3, y=4)
+ res, out, err = py.io.StdCapture.call(func, 3, y=4)
assert res == 42
assert out.startswith("3")
assert err.startswith("4")
-class TestCapturingOnFDs(TestCapturingOnSys):
- def test_reading_stdin_while_captured_doesnt_hang(self):
- py.test.skip("Hangs in py.test --session=R")
-
- def getcapture(self):
- return Capture()
Modified: py/trunk/py/log/testing/test_log.py
==============================================================================
--- py/trunk/py/log/testing/test_log.py (original)
+++ py/trunk/py/log/testing/test_log.py Thu Feb 1 16:20:39 2007
@@ -1,7 +1,8 @@
import py
-from py.__.misc.simplecapture import callcapture
import sys
+callcapture = py.io.StdCapture.call
+
def setup_module(mod):
mod.tempdir = py.test.ensuretemp("py.log-test")
mod.logstate = py.log._getstate()
Deleted: /py/trunk/py/misc/capture.py
==============================================================================
--- /py/trunk/py/misc/capture.py Thu Feb 1 16:20:39 2007
+++ (empty file)
@@ -1,49 +0,0 @@
-
-import os, sys
-
-class FDCapture:
- def __init__(self, targetfd, sysattr=None):
- self.targetfd = targetfd
- self.tmpfile = self.maketmpfile()
- self._savefd = os.dup(targetfd)
- os.dup2(self.tmpfile.fileno(), targetfd)
- if sysattr is not None:
- self._reset = (lambda oldval=getattr(sys, sysattr):
- setattr(sys, sysattr, oldval))
- setattr(sys, sysattr, self.tmpfile)
-
- def done(self):
- os.dup2(self._savefd, self.targetfd)
- if hasattr(self, '_reset'):
- self._reset()
- del self._reset
- os.close(self._savefd)
- f = self.tmpfile
- f.seek(0)
- del self._savefd
- del self.tmpfile
- return f
-
- def maketmpfile(self):
- f = os.tmpfile()
- fd = f.fileno()
- newfd = os.dup(fd)
- newf = os.fdopen(newfd, 'w+b', 0)
- f.close()
- return newf
-
-class Capture:
- def __init__(self):
- self._out = FDCapture(1, 'stdout')
- self._oldsysout = sys.stdout
- sys.stdout = self._out.tmpfile
-
- self._err = FDCapture(2, 'stderr')
- self._olderrout = sys.stderr
- sys.stderr = self._err.tmpfile
-
- def reset(self):
- outfile = self._out.done()
- errfile = self._err.done()
- return outfile.read(), errfile.read()
-
Deleted: /py/trunk/py/misc/simplecapture.py
==============================================================================
--- /py/trunk/py/misc/simplecapture.py Thu Feb 1 16:20:39 2007
+++ (empty file)
@@ -1,58 +0,0 @@
-"""
-
-capture stdout/stderr
-
-"""
-import sys
-try: from cStringIO import StringIO
-except ImportError: from StringIO import StringIO
-
-class SimpleOutErrCapture:
- """ capture sys.stdout/sys.stderr (but not system level fd 1 and 2).
-
- this captures only "In-Memory" and is currently intended to be
- used by the unittest package to capture print-statements in tests.
- """
- def __init__(self):
- self.oldin = sys.stdin
- self.oldout = sys.stdout
- self.olderr = sys.stderr
- sys.stdin = self.newin = DontReadFromInput()
- sys.stdout = self.newout = StringIO()
- sys.stderr = self.newerr = StringIO()
-
- def reset(self):
- """ return captured output and restore sys.stdout/err."""
- x, y = self.done()
- return x.read(), y.read()
-
- def done(self):
- o,e = sys.stdout, sys.stderr
- sys.stdin, sys.stdout, sys.stderr = (
- self.oldin, self.oldout, self.olderr)
- del self.oldin, self.oldout, self.olderr
- o, e = self.newout, self.newerr
- o.seek(0)
- e.seek(0)
- return o,e
-
-class DontReadFromInput:
- """Temporary stub class. Ideally when stdin is accessed, the
- capturing should be turned off, with possibly all data captured
- so far sent to the screen. This should be configurable, though,
- because in automated test runs it is better to crash than
- hang indefinitely.
- """
- def read(self, *args):
- raise IOError("reading from stdin while output is captured")
- readline = read
- readlines = read
- __iter__ = read
-
-def callcapture(func, *args, **kwargs):
- so = SimpleOutErrCapture()
- try:
- res = func(*args, **kwargs)
- finally:
- out, err = so.reset()
- return res, out, err
Deleted: /py/trunk/py/misc/testing/test_simplecapture.py
==============================================================================
--- /py/trunk/py/misc/testing/test_simplecapture.py Thu Feb 1 16:20:39 2007
+++ (empty file)
@@ -1,92 +0,0 @@
-import os, sys
-import py
-from py.__.misc.simplecapture import SimpleOutErrCapture, callcapture
-from py.__.misc.capture import Capture, FDCapture
-
-class TestFDCapture:
- def test_basic(self):
- tmpfile = py.std.os.tmpfile()
- fd = tmpfile.fileno()
- cap = FDCapture(fd)
- os.write(fd, "hello")
- f = cap.done()
- s = f.read()
- assert s == "hello"
-
- def test_stderr(self):
- cap = FDCapture(2, 'stderr')
- print >>sys.stderr, "hello"
- f = cap.done()
- s = f.read()
- assert s == "hello\n"
-
-class TestCapturingOnSys:
-
- def getcapture(self):
- return SimpleOutErrCapture()
-
- def test_capturing_simple(self):
- cap = self.getcapture()
- print "hello world"
- print >>sys.stderr, "hello error"
- out, err = cap.reset()
- assert out == "hello world\n"
- assert err == "hello error\n"
-
- def test_capturing_twice_error(self):
- cap = self.getcapture()
- print "hello"
- cap.reset()
- py.test.raises(AttributeError, "cap.reset()")
-
- def test_capturing_modify_sysouterr_in_between(self):
- oldout = sys.stdout
- olderr = sys.stderr
- cap = self.getcapture()
- print "hello",
- print >>sys.stderr, "world",
- sys.stdout = py.std.StringIO.StringIO()
- sys.stderr = py.std.StringIO.StringIO()
- print "not seen"
- print >>sys.stderr, "not seen"
- out, err = cap.reset()
- assert out == "hello"
- assert err == "world"
- assert sys.stdout == oldout
- assert sys.stderr == olderr
-
- def test_capturing_error_recursive(self):
- cap1 = self.getcapture()
- print "cap1"
- cap2 = self.getcapture()
- print "cap2"
- out2, err2 = cap2.reset()
- py.test.raises(AttributeError, "cap2.reset()")
- out1, err1 = cap1.reset()
- assert out1 == "cap1\n"
- assert out2 == "cap2\n"
-
- def test_reading_stdin_while_captured_doesnt_hang(self):
- cap = self.getcapture()
- try:
- py.test.raises(IOError, raw_input)
- finally:
- cap.reset()
-
-def test_callcapture():
- def func(x, y):
- print x
- print >>py.std.sys.stderr, y
- return 42
-
- res, out, err = callcapture(func, 3, y=4)
- assert res == 42
- assert out.startswith("3")
- assert err.startswith("4")
-
-class TestCapturingOnFDs(TestCapturingOnSys):
- def test_reading_stdin_while_captured_doesnt_hang(self):
- py.test.skip("Hangs in py.test --session=R")
-
- def getcapture(self):
- return Capture()
Modified: py/trunk/py/test/collect.py
==============================================================================
--- py/trunk/py/test/collect.py (original)
+++ py/trunk/py/test/collect.py Thu Feb 1 16:20:39 2007
@@ -379,11 +379,7 @@
def startcapture(self):
if not self.config.option.nocapture:
assert not hasattr(self, '_capture')
- self._capture = py.io.OutErrCapture()
- # XXX integrate this into py.io / refactor
- # execnet/py.test capturing mechanisms
- #from py.__.misc.simplecapture import SimpleOutErrCapture
- #self._capture = SimpleOutErrCapture()
+ self._capture = py.io.StdCaptureFD()
def finishcapture(self):
if hasattr(self, '_capture'):
Modified: py/trunk/py/test/item.py
==============================================================================
--- py/trunk/py/test/item.py (original)
+++ py/trunk/py/test/item.py Thu Feb 1 16:20:39 2007
@@ -32,10 +32,7 @@
class Item(py.test.collect.Collector):
def startcapture(self):
if not self.config.option.nocapture:
- # XXX refactor integrate capturing
- self._capture = py.io.OutErrCapture()
- #from py.__.misc.simplecapture import SimpleOutErrCapture
- #self._capture = SimpleOutErrCapture()
+ self._capture = py.io.StdCaptureFD()
def finishcapture(self):
if hasattr(self, '_capture'):
Modified: py/trunk/py/test/rsession/local.py
==============================================================================
--- py/trunk/py/test/rsession/local.py (original)
+++ py/trunk/py/test/rsession/local.py Thu Feb 1 16:20:39 2007
@@ -2,6 +2,7 @@
""" local-only operations
"""
+import py
from py.__.test.rsession.executor import BoxExecutor, RunExecutor,\
ApigenExecutor
from py.__.test.rsession import report
@@ -9,10 +10,8 @@
# XXX copied from session.py
def startcapture(session):
- if not session.config.option.nocapture and not session.config.option.usepdb:
- # XXX refactor integrate capturing
- from py.__.misc.simplecapture import SimpleOutErrCapture
- session._capture = SimpleOutErrCapture()
+ if not session.config.option.nocapture:
+ session._capture = py.io.StdCapture()
def finishcapture(session):
if hasattr(session, '_capture'):
Modified: py/trunk/py/test/rsession/rsession.py
==============================================================================
--- py/trunk/py/test/rsession/rsession.py (original)
+++ py/trunk/py/test/rsession/rsession.py Thu Feb 1 16:20:39 2007
@@ -259,7 +259,7 @@
raise NotImplementedError("%s does not contain 'build' "
"function" %(apigen,))
print >>sys.stderr, 'building documentation'
- capture = py.io.OutErrCapture()
+ capture = py.io.StdCaptureFD()
try:
pkgdir = self.getpkgdir(self.config.args[0])
apigen.build(pkgdir,
Modified: py/trunk/py/test/rsession/testing/test_reporter.py
==============================================================================
--- py/trunk/py/test/rsession/testing/test_reporter.py (original)
+++ py/trunk/py/test/rsession/testing/test_reporter.py Thu Feb 1 16:20:39 2007
@@ -74,7 +74,7 @@
for outcome in outcomes:
r.report(report.ReceivedItemOutcome(ch, item, outcome))
- cap = py.io.OutErrCapture()
+ cap = py.io.StdCaptureFD()
boxfun(config, item, outcomes)
out, err = cap.reset()
assert not err
@@ -97,7 +97,7 @@
for outcome in outcomes:
r.report(report.ReceivedItemOutcome(ch, funcitem, outcome))
- cap = py.io.OutErrCapture()
+ cap = py.io.StdCaptureFD()
boxfun(self.pkgdir, config, moditem, funcitem, outcomes)
out, err = cap.reset()
assert not err
@@ -125,7 +125,7 @@
r = self.reporter(config, hosts)
list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
- cap = py.io.OutErrCapture()
+ cap = py.io.StdCaptureFD()
boxfun()
out, err = cap.reset()
assert not err
@@ -147,7 +147,7 @@
list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
r.report(report.TestFinished())
- cap = py.io.OutErrCapture()
+ cap = py.io.StdCaptureFD()
boxfun()
out, err = cap.reset()
assert not err
@@ -156,7 +156,7 @@
def _test_still_to_go(self):
tmpdir = py.test.ensuretemp("stilltogo")
tmpdir.ensure("__init__.py")
- cap = py.io.OutErrCapture()
+ cap = py.io.StdCaptureFD()
config = py.test.config._reparse([str(tmpdir)])
hosts = [HostInfo(i) for i in ["host1", "host2", "host3"]]
r = self.reporter(config, hosts)
Modified: py/trunk/py/test/testing/test_session.py
==============================================================================
--- py/trunk/py/test/testing/test_session.py (original)
+++ py/trunk/py/test/testing/test_session.py Thu Feb 1 16:20:39 2007
@@ -189,7 +189,7 @@
import py
class Function(py.test.Function):
def startcapture(self):
- self._mycapture = py.io.OutErrCapture()
+ self._mycapture = py.io.StdCaptureFD()
def finishcapture(self):
self._testmycapture = self._mycapture.reset()
Deleted: /py/trunk/py/test/todo-cleanup.txt
==============================================================================
--- /py/trunk/py/test/todo-cleanup.txt Thu Feb 1 16:20:39 2007
+++ (empty file)
@@ -1,10 +0,0 @@
-
-
-fix --looponfailing: currently in case of failures
-all tests are re-run. the problem was introduced
-while cleaning up session.main() calls ...
-the setup of remote and local config objects
-and collectors needs to be reviewed anyway
-(and the terminalsession and rsession handling
-of such config object should be unified with
-respect to this configuration/failure communication)
Modified: py/trunk/py/thread/testing/test_pool.py
==============================================================================
--- py/trunk/py/thread/testing/test_pool.py (original)
+++ py/trunk/py/thread/testing/test_pool.py Thu Feb 1 16:20:39 2007
@@ -77,7 +77,7 @@
pool.join(timeout=0.1)
def test_pool_clean_shutdown():
- capture = py.io.OutErrCapture()
+ capture = py.io.StdCaptureFD()
pool = WorkerPool()
def f():
pass
More information about the pytest-commit
mailing list