[py-svn] r61202 - in py/branch/pytestplugin/py/test: attic attic/testing report

hpk at codespeak.net hpk at codespeak.net
Wed Jan 21 17:44:22 CET 2009


Author: hpk
Date: Wed Jan 21 17:44:21 2009
New Revision: 61202

Added:
   py/branch/pytestplugin/py/test/attic/   (props changed)
      - copied from r61020, py/branch/pytestplugin/py/test/report/
Removed:
   py/branch/pytestplugin/py/test/attic/base.py
   py/branch/pytestplugin/py/test/attic/collectonly.py
   py/branch/pytestplugin/py/test/attic/terminal.py
   py/branch/pytestplugin/py/test/attic/testing/test_basereporter.py
   py/branch/pytestplugin/py/test/attic/testing/test_collectonly.py
   py/branch/pytestplugin/py/test/attic/testing/test_terminal.py
   py/branch/pytestplugin/py/test/report/
Log:
move away all the old reporters to the py.test "attic" 


Deleted: /py/branch/pytestplugin/py/test/report/base.py
==============================================================================
--- /py/branch/pytestplugin/py/test/report/base.py	Wed Jan 21 17:44:21 2009
+++ (empty file)
@@ -1,74 +0,0 @@
-from py.__.test import event
-from py.__.test.collect import getrelpath
-
-import sys
-
-class BaseReporter(object):
-    def __init__(self, bus=None):
-        self._reset()
-        self._bus = bus
-        if bus:
-            self._bus.subscribe(self.processevent)
-
-    def _reset(self):
-        self._passed = []
-        self._skipped = []
-        self._failed = []
-        self._deselected = []
-
-    def deactivate(self):
-        if self._bus:
-            self._bus.unsubscribe(self.processevent)
-
-    def processevent(self, ev):
-        evname = ev.__class__.__name__ 
-        repmethod = getattr(self, "rep_%s" % evname, None)
-        if repmethod is None:
-            self.rep(ev)
-        else:
-            repmethod(ev)
-
-    def rep(self, ev):
-        pass
-
-    def rep_ItemTestReport(self, ev):
-        if ev.skipped:
-            self._skipped.append(ev)
-        elif ev.failed:
-            self._failed.append(ev)
-        elif ev.passed:
-            self._passed.append(ev)
-
-    def rep_CollectionReport(self, ev):
-        if ev.skipped:
-            self._skipped.append(ev)
-        elif ev.failed:
-            self._failed.append(ev)
-        else:
-            pass # don't record passed collections 
-
-    def rep_TestrunStart(self, ev):
-        self._reset()
-
-    def rep_Deselected(self, ev):
-        self._deselected.extend(ev.items)
-
-    def _folded_skips(self):
-        d = {}
-        for event in self._skipped:
-            longrepr = event.outcome.longrepr
-            key = longrepr.path, longrepr.lineno, longrepr.message
-            d.setdefault(key, []).append(event)
-        l = []
-        for key, events in d.iteritems(): 
-            l.append((len(events),) + key)
-        return l 
-
-def repr_pythonversion(v=None):
-    if v is None:
-        v = sys.version_info
-    try:
-        return "%s.%s.%s-%s-%s" % v
-    except (TypeError, ValueError):
-        return str(v)
-

Deleted: /py/branch/pytestplugin/py/test/report/collectonly.py
==============================================================================
--- /py/branch/pytestplugin/py/test/report/collectonly.py	Wed Jan 21 17:44:21 2009
+++ (empty file)
@@ -1,43 +0,0 @@
-
-""" --collectonly session, not to spread logic all over the place
-"""
-import py
-from py.__.test.report.base import BaseReporter 
-from py.__.test.outcome import Skipped as Skipped2
-from py.__.test.outcome import Skipped
-
-class CollectonlyReporter(BaseReporter):
-    INDENT = "  "
-
-    def __init__(self, config, out=None, bus=None):
-        super(CollectonlyReporter, self).__init__(bus=bus)
-        self.config = config
-        if out is None:
-            out = py.std.sys.stdout
-        self.out = py.io.TerminalWriter(out)
-        self.indent = ""
-        self._failed = []
-
-    def outindent(self, line):
-        self.out.line(self.indent + str(line))
-
-    def rep_CollectionStart(self, ev):
-        self.outindent(ev.collector)
-        self.indent += self.INDENT 
-    
-    def rep_ItemStart(self, event):
-        self.outindent(event.item)
-
-    def rep_CollectionReport(self, ev):
-        super(CollectonlyReporter, self).rep_CollectionReport(ev)
-        if ev.failed:
-            self.outindent("!!! %s !!!" % ev.outcome.longrepr.reprcrash.message)
-        elif ev.skipped:
-            self.outindent("!!! %s !!!" % ev.outcome.longrepr.message)
-        self.indent = self.indent[:-len(self.INDENT)]
-
-    def rep_TestrunFinish(self, session):
-        for ev in self._failed:
-            ev.toterminal(self.out)
-                
-Reporter = CollectonlyReporter

Deleted: /py/branch/pytestplugin/py/test/report/terminal.py
==============================================================================
--- /py/branch/pytestplugin/py/test/report/terminal.py	Wed Jan 21 17:44:21 2009
+++ (empty file)
@@ -1,219 +0,0 @@
-import py
-import sys
-from py.__.test import event
-from py.__.test.report.base import BaseReporter
-from py.__.test.report.base import getrelpath, repr_pythonversion
-
-class TerminalReporter(BaseReporter):
-    def __init__(self, config, file=None, bus=None):
-        super(TerminalReporter, self).__init__(bus=bus)
-        self.config = config
-        self.curdir = py.path.local()
-        if file is None:
-            file = py.std.sys.stdout
-        self._tw = py.io.TerminalWriter(file)
-
-    def _reset(self):
-        self.currentfspath = None 
-        super(TerminalReporter, self)._reset()
-
-    def write_fspath_result(self, fspath, res):
-        if fspath != self.currentfspath:
-            self._tw.line()
-            relpath = getrelpath(self.curdir, fspath)
-            self._tw.write(relpath + " ")
-            self.currentfspath = fspath
-        self._tw.write(res)
-
-    def write_ensure_prefix(self, prefix, extra=""):
-        if self.currentfspath != prefix:
-            self._tw.line()
-            self.currentfspath = prefix 
-            self._tw.write(prefix)
-        if extra:
-            self._tw.write(extra)
-            self.currentfspath = -2
-
-    def ensure_newline(self):
-        if self.currentfspath: 
-            self._tw.line()
-            self.currentfspath = None
-
-    def write_line(self, line, **markup):
-        line = str(line)
-        self.ensure_newline()
-        self._tw.line(line, **markup)
-
-    def write_sep(self, sep, title=None, **markup):
-        self.ensure_newline()
-        self._tw.sep(sep, title, **markup)
-
-    def getoutcomeletter(self, item):
-        return item.outcome.shortrepr
-
-    def getoutcomeword(self, item):
-        if item.passed: return self._tw.markup("PASS", green=True)
-        elif item.failed: return self._tw.markup("FAIL", red=True)
-        elif item.skipped: return "SKIP"
-        else: return self._tw.markup("???", red=True)
-
-    def getcollectoutcome(self, item):
-        if item.skipped:
-            return str(item.outcome.longrepr.message)
-        else:
-            return str(item.outcome.longrepr.reprcrash.message)
-
-    def rep_InternalException(self, ev):
-        for line in str(ev.repr).split("\n"):
-            self.write_line("InternalException: " + line)
-
-    def rep_HostGatewayReady(self, ev):
-        if self.config.option.verbose:
-            self.write_line("HostGatewayReady: %s" %(ev.host,))
-
-    def rep_HostUp(self, ev):
-        d = ev.platinfo.copy()
-        d['hostid'] = ev.host.hostid
-        d['version'] = repr_pythonversion(d['sys.version_info'])
-        self.write_line("HOSTUP: %(hostid)s %(sys.platform)s "
-                      "%(sys.executable)s - Python %(version)s" %
-                      d)
-
-    def rep_HostDown(self, ev):
-        host = ev.host
-        error = ev.error
-        if error:
-            self.write_line("HostDown %s: %s" %(host.hostid, error))
-
-    def rep_ItemStart(self, ev):
-        if self.config.option.verbose:
-            info = ev.item.repr_metainfo()
-            line = info.verboseline(basedir=self.curdir) + " "
-            extra = ""
-            if ev.host:
-                extra = "-> " + ev.host.hostid
-            self.write_ensure_prefix(line, extra)
-        else:
-            # ensure that the path is printed before the 1st test of
-            # a module starts running
-            fspath = ev.item.fspath 
-            self.write_fspath_result(fspath, "")
-
-    def rep_RescheduleItems(self, ev):
-        if self.config.option.debug:
-            self.write_sep("!", "RESCHEDULING %s " %(ev.items,))
-    
-    def rep_ItemTestReport(self, ev):
-        super(TerminalReporter, self).rep_ItemTestReport(ev)
-        fspath = ev.colitem.fspath 
-        if not self.config.option.verbose:
-            self.write_fspath_result(fspath, self.getoutcomeletter(ev))
-        else:
-            info = ev.colitem.repr_metainfo()
-            line = info.verboseline(basedir=self.curdir) + " "
-            word = self.getoutcomeword(ev)
-            self.write_ensure_prefix(line, word)
-
-    def rep_CollectionReport(self, ev):
-        super(TerminalReporter, self).rep_CollectionReport(ev)
-        fspath = ev.colitem.fspath 
-        if ev.failed or ev.skipped:
-            msg = self.getcollectoutcome(ev)
-            self.write_fspath_result(fspath, "- " + msg)
-
-    def rep_TestrunStart(self, ev):
-        super(TerminalReporter, self).rep_TestrunStart(ev)
-        self.write_sep("=", "test session starts", bold=True)
-        self._sessionstarttime = py.std.time.time()
-        #self.out_hostinfo()
-
-    def rep_TestrunFinish(self, ev):
-        self._tw.line("")
-        if ev.exitstatus in (0, 1, 2):
-            self.summary_failures()
-            self.summary_skips()
-        if ev.excrepr is not None:
-            self.summary_final_exc(ev.excrepr)
-        if ev.exitstatus == 2:
-            self.write_sep("!", "KEYBOARD INTERRUPT")
-        self.summary_deselected()
-        self.summary_stats()
-
-    def rep_LooponfailingInfo(self, ev):
-        if ev.failreports:
-            self.write_sep("#", "LOOPONFAILING", red=True)
-            for report in ev.failreports:
-                try:
-                    loc = report.outcome.longrepr.reprcrash
-                except AttributeError:
-                    loc = str(report.outcome.longrepr)[:50]
-                self.write_line(loc, red=True)
-        self.write_sep("#", "waiting for changes")
-        for rootdir in ev.rootdirs:
-            self.write_line("### Watching:   %s" %(rootdir,), bold=True)
-
-        if 0:
-            print "#" * 60
-            print "# looponfailing: mode: %d failures args" % len(failures)
-            for ev in failurereports:
-                name = "/".join(ev.colitem.listnames()) # XXX
-                print "Failure at: %r" % (name,) 
-            print "#    watching py files below %s" % rootdir
-            print "#                           ", "^" * len(str(rootdir))
-            failures = [ev.colitem for ev in failurereports]
-            if not failures:
-                failures = colitems 
-
-    #
-    # summaries for TestrunFinish 
-    #
-
-    def summary_failures(self):
-        if self._failed and self.config.option.tbstyle != "no":
-            self.write_sep("=", "FAILURES")
-            for ev in self._failed:
-                self.write_sep("_")
-                ev.toterminal(self._tw)
-
-    def summary_stats(self):
-        session_duration = py.std.time.time() - self._sessionstarttime
-        numfailed = len(self._failed)
-        numskipped = len(self._skipped)
-        numpassed = len(self._passed)
-        sum = numfailed + numpassed
-        self.write_sep("=", "%d/%d passed + %d skips in %.2f seconds" %
-                      (numpassed, sum, numskipped, session_duration), bold=True)
-        if numfailed == 0:
-            self.write_sep("=", "failures: no failures :)", green=True)
-        else:
-            self.write_sep("=", "failures: %d" %(numfailed), red=True)
-
-    def summary_deselected(self):
-        if not self._deselected:
-            return
-        self.write_sep("=", "%d tests deselected by %r" %(
-            len(self._deselected), self.config.option.keyword), bold=True)
-                                                
-
-    def summary_skips(self):
-        if not self._failed or self.config.option.showskipsummary:
-            folded_skips = self._folded_skips()
-            if folded_skips:
-                self.write_sep("_", "skipped test summary")
-                for num, fspath, lineno, reason in folded_skips:
-                    self._tw.line("%s:%d: [%d] %s" %(fspath, lineno, num, reason))
-
-    def summary_final_exc(self, excrepr):
-        self.write_sep("!")
-        if self.config.option.verbose:
-            excrepr.toterminal(self._tw)
-        else:
-            excrepr.reprcrash.toterminal(self._tw)
-
-    def out_hostinfo(self):
-        self._tw.line("host 0: %s %s - Python %s" %
-                       (py.std.sys.platform, 
-                        py.std.sys.executable, 
-                        repr_pythonversion()))
-
-Reporter = TerminalReporter 

Deleted: /py/branch/pytestplugin/py/test/report/testing/test_basereporter.py
==============================================================================
--- /py/branch/pytestplugin/py/test/report/testing/test_basereporter.py	Wed Jan 21 17:44:21 2009
+++ (empty file)
@@ -1,94 +0,0 @@
-import py
-from py.__.test.report.base import BaseReporter
-from py.__.test.event import EventBus
-from py.__.test import event
-from py.__.test.runner import OutcomeRepr
-from py.__.test.report.base import getrelpath, repr_pythonversion
-import sys
-
-class TestBaseReporter:
-    def test_activate(self):
-        bus = EventBus()
-        rep = BaseReporter(bus=bus)
-        assert bus._subscribers
-        assert rep.processevent in bus._subscribers
-        rep.deactivate()
-        assert not bus._subscribers
-
-    def test_dispatch_to_matching_method(self):
-        l = []
-        class MyReporter(BaseReporter):
-            def rep_TestrunStart(self, ev):
-                l.append(ev)
-        rep = MyReporter()
-        ev = event.TestrunStart()
-        rep.processevent(ev)
-        assert len(l) == 1
-        assert l[0] is ev
-
-    def test_dispatch_to_default(self):
-        l = []
-        class MyReporter(BaseReporter):
-            def rep(self, ev):
-                l.append(ev)
-        rep = MyReporter()
-        ev = event.NOP()
-        rep.processevent(ev)
-        assert len(l) == 1
-        assert l[0] is ev
-
-    def test_TestItemReport_one(self):
-        for outcome in 'passed skipped failed'.split():
-            rep = BaseReporter()
-            ev = event.ItemTestReport(None, **{outcome:True})
-            rep.processevent(ev)
-            assert getattr(rep, '_' + outcome) == [ev]
-
-    def test_CollectionReport(self):
-        for outcome in 'skipped failed'.split():
-            rep = BaseReporter()
-            ev = event.CollectionReport(None, None, **{outcome:True})
-            rep.processevent(ev)
-            assert getattr(rep, '_' + outcome) == [ev]
-
-    def test_skip_reasons(self):
-        rep = BaseReporter()
-        class longrepr:
-            path = 'xyz'
-            lineno = 3
-            message = "justso"
-        out1 = OutcomeRepr(None, None, longrepr)
-        out2 = OutcomeRepr(None, None, longrepr)
-        ev1 = event.CollectionReport(None, None, skipped=out1)
-        ev2 = event.ItemTestReport(None, skipped=out2)
-        rep.processevent(ev1)
-        rep.processevent(ev2)
-        assert len(rep._skipped) == 2
-        l = rep._folded_skips()
-        assert len(l) == 1
-        num, fspath, lineno, reason = l[0]
-        assert num == 2
-        assert fspath == longrepr.path
-        assert lineno == longrepr.lineno
-        assert reason == longrepr.message
-
-def test_repr_python_version():
-    py.magic.patch(sys, 'version_info', (2, 5, 1, 'final', 0))
-    try:
-        assert repr_pythonversion() == "2.5.1-final-0"
-        py.std.sys.version_info = x = (2,3)
-        assert repr_pythonversion() == str(x) 
-    finally: 
-        py.magic.revert(sys, 'version_info') 
-
-def test_getrelpath():
-    curdir = py.path.local()
-    sep = curdir.sep
-    s = getrelpath(curdir, curdir.join("hello", "world"))
-    assert s == "hello" + sep + "world"
-
-    s = getrelpath(curdir, curdir.dirpath().join("sister"))
-    assert s == ".." + sep + "sister"
-    assert getrelpath(curdir, curdir.dirpath()) == ".."
-    
-    assert getrelpath(curdir, "hello") == "hello"

Deleted: /py/branch/pytestplugin/py/test/report/testing/test_collectonly.py
==============================================================================
--- /py/branch/pytestplugin/py/test/report/testing/test_collectonly.py	Wed Jan 21 17:44:21 2009
+++ (empty file)
@@ -1,53 +0,0 @@
-import py
-from py.__.test.report.collectonly import CollectonlyReporter
-from py.__.test import event
-from py.__.test.testing.suptest import InlineCollection, popvalue
-from py.__.test.testing.suptest import assert_stringio_contains_lines
-
-class TestCollectonly(InlineCollection):
-    def test_collectonly_basic(self):
-        modcol = self.getmodulecol(configargs=['--collectonly'], source="""
-            def test_func():
-                pass
-        """)
-        stringio = py.std.cStringIO.StringIO()
-        rep = CollectonlyReporter(modcol._config, out=stringio)
-        indent = rep.indent
-        rep.processevent(event.CollectionStart(modcol))
-        s = popvalue(stringio)
-        assert s == "<Module 'test_TestCollectonly_test_collectonly_basic.py'>"
-
-        item = modcol.join("test_func")
-        rep.processevent(event.ItemStart(item))
-        s = popvalue(stringio)
-        assert s.find("Function 'test_func'") != -1
-        rep.processevent(event.CollectionReport(modcol, [], passed=""))
-        assert rep.indent == indent 
-
-    def test_collectonly_skipped_module(self):
-        modcol = self.getmodulecol(configargs=['--collectonly'], source="""
-            import py
-            py.test.skip("nomod")
-        """, withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = CollectonlyReporter(modcol._config, bus=self.session.bus, out=stringio)
-        cols = list(self.session.genitems([modcol]))
-        assert len(cols) == 0
-        assert_stringio_contains_lines(stringio, """
-            <Module 'test_TestCollectonly_test_collectonly_skipped_module.py'>
-              !!! Skipped: 'nomod' !!!
-        """)
-
-    def test_collectonly_failed_module(self):
-        modcol = self.getmodulecol(configargs=['--collectonly'], source="""
-            raise ValueError(0)
-        """, withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = CollectonlyReporter(modcol._config, bus=self.session.bus, out=stringio)
-        cols = list(self.session.genitems([modcol]))
-        assert len(cols) == 0
-        assert_stringio_contains_lines(stringio, """
-            <Module 'test_TestCollectonly_test_collectonly_failed_module.py'>
-              !!! ValueError: 0 !!!
-        """)
-

Deleted: /py/branch/pytestplugin/py/test/report/testing/test_terminal.py
==============================================================================
--- /py/branch/pytestplugin/py/test/report/testing/test_terminal.py	Wed Jan 21 17:44:21 2009
+++ (empty file)
@@ -1,247 +0,0 @@
-import py
-import sys
-from py.__.test.report.terminal import TerminalReporter
-from py.__.test import event
-#from py.__.test.testing import suptest
-from py.__.test.runner import basic_run_report
-from py.__.test.testing.suptest import InlineCollection, popvalue 
-from py.__.test.testing.suptest import assert_stringio_contains_lines
-from py.__.test.dsession.hostmanage import Host, makehostup
-from py.__.test.report.base import repr_pythonversion
-
-class TestTerminal(InlineCollection):
-    def test_session_reporter_subscription(self):
-        config = py.test.config._reparse(['xxx'])
-        session = config.initsession()
-        session.sessionstarts()
-        rep = session.reporter
-        assert isinstance(rep, TerminalReporter)
-        assert rep.processevent in session.bus._subscribers
-        session.sessionfinishes()
-        #assert rep.processevent not in session.bus._subscribers
-
-    def test_hostup(self):
-        item = self.getitem("def test_func(): pass")
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(item._config, file=stringio)
-        rep.processevent(event.TestrunStart())
-        host = Host("localhost")
-        rep.processevent(makehostup(host))
-        s = popvalue(stringio)
-        expect = "%s %s %s - Python %s" %(host.hostid, sys.platform, 
-            sys.executable, repr_pythonversion(sys.version_info))
-        assert s.find(expect) != -1
-
-    def test_pass_skip_fail(self):
-        modcol = self.getmodulecol("""
-            import py
-            def test_ok():
-                pass
-            def test_skip():
-                py.test.skip("xx")
-            def test_func():
-                assert 0
-        """, withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, file=stringio)
-        rep.processevent(event.TestrunStart())
-        for item in self.session.genitems([modcol]):
-            ev = basic_run_report(item) 
-            rep.processevent(ev)
-        s = popvalue(stringio)
-        assert s.find("test_pass_skip_fail.py .sF") != -1
-        rep.processevent(event.TestrunFinish())
-        assert_stringio_contains_lines(stringio, [
-            "    def test_func():",
-            ">       assert 0",
-            "E       assert 0",
-        ])
-
-    def test_pass_skip_fail_verbose(self):
-        modcol = self.getmodulecol("""
-            import py
-            def test_ok():
-                pass
-            def test_skip():
-                py.test.skip("xx")
-            def test_func():
-                assert 0
-        """, configargs=("-v",), withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, file=stringio)
-        rep.processevent(event.TestrunStart())
-        items = modcol.collect()
-        for item in items:
-            rep.processevent(event.ItemStart(item))
-            s = stringio.getvalue().strip()
-            assert s.endswith(item.name)
-            ev = basic_run_report(item) 
-            rep.processevent(ev)
-
-        assert_stringio_contains_lines(stringio, [
-            "*test_pass_skip_fail_verbose.py:2: *test_ok*PASS",
-            "*test_pass_skip_fail_verbose.py:4: *test_skip*SKIP",
-            "*test_pass_skip_fail_verbose.py:6: *test_func*FAIL",
-        ])
-        rep.processevent(event.TestrunFinish())
-        assert_stringio_contains_lines(stringio, [
-            "    def test_func():",
-            ">       assert 0",
-            "E       assert 0",
-        ])
-
-    def test_collect_fail(self):
-        modcol = self.getmodulecol("""
-            import xyz
-        """, withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, bus=self.session.bus, file=stringio)
-        rep.processevent(event.TestrunStart())
-        l = list(self.session.genitems([modcol]))
-        assert len(l) == 0
-        s = popvalue(stringio) 
-        print s
-        assert s.find("test_collect_fail.py - ImportError: No module named") != -1
-        rep.processevent(event.TestrunFinish())
-        assert_stringio_contains_lines(stringio, [
-            ">   import xyz",
-            "E   ImportError: No module named xyz"
-        ])
-
-    def test_internal_exception(self):
-        modcol = self.getmodulecol("def test_one(): pass")
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, file=stringio)
-        excinfo = py.test.raises(ValueError, "raise ValueError('hello')")
-        rep.processevent(event.InternalException(excinfo))
-        s = popvalue(stringio)
-        assert s.find("InternalException:") != -1 
-
-    def test_hostready_crash(self):
-        modcol = self.getmodulecol("""
-            def test_one():
-                pass
-        """, configargs=("-v",))
-        stringio = py.std.cStringIO.StringIO()
-        host1 = Host("localhost")
-        rep = TerminalReporter(modcol._config, file=stringio)
-        rep.processevent(event.HostGatewayReady(host1, None))
-        s = popvalue(stringio)
-        assert s.find("HostGatewayReady") != -1
-        rep.processevent(event.HostDown(host1, "myerror"))
-        s = popvalue(stringio)
-        assert s.find("HostDown") != -1
-        assert s.find("myerror") != -1
-
-    def test_writeline(self):
-        modcol = self.getmodulecol("def test_one(): pass")
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, file=stringio)
-        rep.write_fspath_result(py.path.local("xy.py"), '.')
-        rep.write_line("hello world")
-        lines = popvalue(stringio).split('\n')
-        assert not lines[0]
-        assert lines[1].endswith("xy.py .")
-        assert lines[2] == "hello world"
-
-    def test_looponfailingreport(self):
-        modcol = self.getmodulecol("""
-            def test_fail():
-                assert 0
-            def test_fail2():
-                raise ValueError()
-        """)
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, file=stringio)
-        reports = [basic_run_report(x) for x in modcol.collect()]
-        rep.processevent(event.LooponfailingInfo(reports, [modcol._config.topdir]))
-        assert_stringio_contains_lines(stringio, [
-            "*test_looponfailingreport.py:2: assert 0",
-            "*test_looponfailingreport.py:4: ValueError*",
-            "*waiting*", 
-            "*%s*" % (modcol._config.topdir),
-        ])
-
-    def test_tb_option(self):
-        for tbopt in ["no", "short", "long"]:
-            print 'testing --tb=%s...' % tbopt
-            modcol = self.getmodulecol("""
-                import py
-                def g():
-                    raise IndexError
-                def test_func():
-                    print 6*7
-                    g()  # --calling--
-            """, configargs=("--tb=%s" % tbopt,), withsession=True)
-            stringio = py.std.cStringIO.StringIO()
-            rep = TerminalReporter(modcol._config, file=stringio)
-            rep.processevent(event.TestrunStart())
-            for item in self.session.genitems([modcol]):
-                ev = basic_run_report(item) 
-                rep.processevent(ev)
-            rep.processevent(event.TestrunFinish())
-            s = popvalue(stringio)
-            if tbopt == "long":
-                assert 'print 6*7' in s
-            else:
-                assert 'print 6*7' not in s
-            if tbopt != "no":
-                assert '--calling--' in s
-                assert 'IndexError' in s
-            else:
-                assert 'FAILURES' not in s
-                assert '--calling--' not in s
-                assert 'IndexError' not in s
-
-    def test_show_path_before_running_test(self):
-        modcol = self.getmodulecol("""
-            def test_foobar():
-                pass
-        """, withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, bus=self.session.bus, file=stringio)
-        l = list(self.session.genitems([modcol]))
-        assert len(l) == 1
-        rep.processevent(event.ItemStart(l[0]))
-        s = popvalue(stringio) 
-        print s
-        assert s.find("test_show_path_before_running_test.py") != -1
-
-    def test_keyboard_interrupt(self, verbose=False):
-        modcol = self.getmodulecol("""
-            def test_foobar():
-                assert 0
-            def test_spamegg():
-                import py; py.test.skip('skip me please!')
-            def test_interrupt_me():
-                raise KeyboardInterrupt   # simulating the user
-        """, configargs=("--showskipsummary",) + ("-v",)*verbose,
-             withsession=True)
-        stringio = py.std.cStringIO.StringIO()
-        rep = TerminalReporter(modcol._config, bus=self.session.bus, file=stringio)
-        rep.processevent(event.TestrunStart())
-        try:
-            for item in self.session.genitems([modcol]):
-                ev = basic_run_report(item) 
-                rep.processevent(ev)
-        except KeyboardInterrupt:
-            excinfo = py.code.ExceptionInfo()
-        else:
-            py.test.fail("no KeyboardInterrupt??")
-        s = popvalue(stringio)
-        if not verbose:
-            assert s.find("_keyboard_interrupt.py Fs") != -1
-        rep.processevent(event.TestrunFinish(exitstatus=2, excinfo=excinfo))
-        assert_stringio_contains_lines(stringio, [
-            "    def test_foobar():",
-            ">       assert 0",
-            "E       assert 0",
-        ])
-        text = stringio.getvalue()
-        assert "Skipped: 'skip me please!'" in text
-        assert "_keyboard_interrupt.py:6: KeyboardInterrupt" in text
-        see_details = "raise KeyboardInterrupt   # simulating the user" in text
-        assert see_details == verbose
-
-    def test_verbose_keyboard_interrupt(self):
-        self.test_keyboard_interrupt(verbose=True)



More information about the pytest-commit mailing list