* rename "rep" to "report" in reporting hooks

* refine docs
* bump version data
* improve announcement

--HG--
branch : 1.0.x
This commit is contained in:
holger krekel
2009-08-04 12:00:04 +02:00
parent 67c4503d1b
commit 8c8617c354
27 changed files with 181 additions and 603 deletions

View File

@@ -33,7 +33,7 @@ def pytest_collect_file(path, parent):
def pytest_collectstart(collector):
""" collector starts collecting. """
def pytest_collectreport(rep):
def pytest_collectreport(report):
""" collector finished collecting. """
def pytest_deselected(items):
@@ -83,7 +83,7 @@ def pytest_runtest_makereport(item, call):
""" make ItemTestReport for the given item and call outcome. """
pytest_runtest_makereport.firstresult = True
def pytest_runtest_logreport(rep):
def pytest_runtest_logreport(report):
""" process item test report. """
# special handling for final teardown - somewhat internal for now

View File

@@ -132,8 +132,8 @@ class TestDoctests:
""")
reprec = testdir.inline_run(p)
call = reprec.getcall("pytest_runtest_logreport")
assert call.rep.failed
assert call.rep.longrepr
assert call.report.failed
assert call.report.longrepr
# XXX
#testitem, = items
#excinfo = py.test.raises(Failed, "testitem.runtest()")

View File

@@ -341,7 +341,7 @@ class ReportRecorder(object):
# functionality for test reports
def getreports(self, names="pytest_runtest_logreport pytest_collectreport"):
return [x.rep for x in self.getcalls(names)]
return [x.report for x in self.getcalls(names)]
def matchreport(self, inamepart="", names="pytest_runtest_logreport pytest_collectreport"):
""" return a testreport whose dotted import path matches """
@@ -406,7 +406,7 @@ def test_reportrecorder(testdir):
skipped = False
when = "call"
recorder.hook.pytest_runtest_logreport(rep=rep)
recorder.hook.pytest_runtest_logreport(report=rep)
failures = recorder.getfailures()
assert failures == [rep]
failures = recorder.getfailures()
@@ -420,14 +420,14 @@ def test_reportrecorder(testdir):
when = "call"
rep.passed = False
rep.skipped = True
recorder.hook.pytest_runtest_logreport(rep=rep)
recorder.hook.pytest_runtest_logreport(report=rep)
modcol = testdir.getmodulecol("")
rep = modcol.config.hook.pytest_make_collect_report(collector=modcol)
rep.passed = False
rep.failed = True
rep.skipped = False
recorder.hook.pytest_collectreport(rep=rep)
recorder.hook.pytest_collectreport(report=rep)
passed, skipped, failed = recorder.listoutcomes()
assert not passed and skipped and failed
@@ -440,7 +440,7 @@ def test_reportrecorder(testdir):
recorder.unregister()
recorder.clear()
recorder.hook.pytest_runtest_logreport(rep=rep)
recorder.hook.pytest_runtest_logreport(report=rep)
py.test.raises(ValueError, "recorder.getfailures()")
class LineComp:

View File

@@ -59,25 +59,25 @@ class ResultLog(object):
testpath = generic_path(node)
self.write_log_entry(testpath, shortrepr, longrepr)
def pytest_runtest_logreport(self, rep):
code = rep.shortrepr
if rep.passed:
def pytest_runtest_logreport(self, report):
code = report.shortrepr
if report.passed:
longrepr = ""
elif rep.failed:
longrepr = str(rep.longrepr)
elif rep.skipped:
longrepr = str(rep.longrepr.reprcrash.message)
self.log_outcome(rep.item, code, longrepr)
elif report.failed:
longrepr = str(report.longrepr)
elif report.skipped:
longrepr = str(report.longrepr.reprcrash.message)
self.log_outcome(report.item, code, longrepr)
def pytest_collectreport(self, rep):
if not rep.passed:
if rep.failed:
def pytest_collectreport(self, report):
if not report.passed:
if report.failed:
code = "F"
else:
assert rep.skipped
assert report.skipped
code = "S"
longrepr = str(rep.longrepr.reprcrash)
self.log_outcome(rep.collector, code, longrepr)
longrepr = str(report.longrepr.reprcrash)
self.log_outcome(report.collector, code, longrepr)
def pytest_internalerror(self, excrepr):
path = excrepr.reprcrash.path

View File

@@ -40,7 +40,7 @@ def pytest_runtest_protocol(item):
if item.config.getvalue("boxed"):
reports = forked_run_report(item)
for rep in reports:
item.config.hook.pytest_runtest_logreport(rep=rep)
item.config.hook.pytest_runtest_logreport(report=rep)
else:
runtestprotocol(item)
return True
@@ -89,7 +89,7 @@ def call_and_report(item, when, log=True):
hook = item.config.hook
report = hook.pytest_runtest_makereport(item=item, call=call)
if log and (when == "call" or not report.passed):
hook.pytest_runtest_logreport(rep=report)
hook.pytest_runtest_logreport(report=report)
return report
def call_runtest_hook(item, when):

View File

@@ -187,7 +187,8 @@ class TerminalReporter:
def pytest__teardown_final_logerror(self, rep):
self.stats.setdefault("error", []).append(rep)
def pytest_runtest_logreport(self, rep):
def pytest_runtest_logreport(self, report):
rep = report
cat, letter, word = self.getcategoryletterword(rep)
if not letter and not word:
# probably passed setup/teardown
@@ -212,15 +213,15 @@ class TerminalReporter:
self._tw.write(" " + line)
self.currentfspath = -2
def pytest_collectreport(self, rep):
if not rep.passed:
if rep.failed:
self.stats.setdefault("error", []).append(rep)
msg = rep.longrepr.reprcrash.message
self.write_fspath_result(rep.collector.fspath, "E")
elif rep.skipped:
self.stats.setdefault("skipped", []).append(rep)
self.write_fspath_result(rep.collector.fspath, "S")
def pytest_collectreport(self, report):
if not report.passed:
if report.failed:
self.stats.setdefault("error", []).append(report)
msg = report.longrepr.reprcrash.message
self.write_fspath_result(report.collector.fspath, "E")
elif report.skipped:
self.stats.setdefault("skipped", []).append(report)
self.write_fspath_result(report.collector.fspath, "S")
def pytest_sessionstart(self, session):
self.write_sep("=", "test session starts", bold=True)
@@ -417,10 +418,10 @@ class CollectonlyReporter:
def pytest_itemstart(self, item, node=None):
self.outindent(item)
def pytest_collectreport(self, rep):
if not rep.passed:
self.outindent("!!! %s !!!" % rep.longrepr.reprcrash.message)
self._failed.append(rep)
def pytest_collectreport(self, report):
if not report.passed:
self.outindent("!!! %s !!!" % report.longrepr.reprcrash.message)
self._failed.append(report)
self.indent = self.indent[:-len(self.INDENT)]
def pytest_sessionfinish(self, session, exitstatus):

View File

@@ -311,7 +311,7 @@ class TestCollectonly:
" <Function 'test_func'>",
])
rep.config.hook.pytest_collectreport(
rep=runner.CollectReport(modcol, [], excinfo=None))
report=runner.CollectReport(modcol, [], excinfo=None))
assert rep.indent == indent
def test_collectonly_skipped_module(self, testdir, linecomp):