remove pytest_report_iteminfo hook, i strongly guess nobody needs or uses it.

This commit is contained in:
holger krekel 2010-11-04 23:21:23 +01:00
parent 28d51e26a0
commit 5251653fc3
8 changed files with 21 additions and 56 deletions

View File

@ -20,7 +20,7 @@ def pytest_cmdline_parse(pluginmanager, args):
pytest_cmdline_parse.firstresult = True
def pytest_addoption(parser):
"""add optparse-style options and ini-style config values via calls
"""add optparse-style options and ini-style config values via calls
to ``parser.addoption`` and ``parser.addini(...)``.
"""
@ -194,14 +194,6 @@ pytest_report_teststatus.firstresult = True
def pytest_terminal_summary(terminalreporter):
""" add additional section in terminal summary reporting. """
def pytest_report_iteminfo(item):
""" return (fspath, lineno, domainpath) location info for the item.
the information is used for result display and to sort tests.
fspath,lineno: file and linenumber of source of item definition.
domainpath: custom id - e.g. for python: dotted import address
"""
pytest_report_iteminfo.firstresult = True
# -------------------------------------------------------------------------
# doctest hooks
# -------------------------------------------------------------------------

View File

@ -49,19 +49,6 @@ def pytest_runtest_makereport(__multicall__, item, call):
call2 = call.__class__(lambda: py.test.skip(str(call.excinfo.value)), call.when)
call.excinfo = call2.excinfo
def pytest_report_iteminfo(item):
# nose 0.11.1 uses decorators for "raises" and other helpers.
# for reporting progress by filename we fish for the filename
if isinstance(item, py.test.collect.Function):
obj = item.obj
if hasattr(obj, 'compat_co_firstlineno'):
fn = sys.modules[obj.__module__].__file__
if fn.endswith(".pyc"):
fn = fn[:-1]
#assert 0
#fn = inspect.getsourcefile(obj) or inspect.getfile(obj)
lineno = obj.compat_co_firstlineno
return py.path.local(fn), lineno, obj.__module__
def pytest_runtest_setup(item):
if isinstance(item, (py.test.collect.Function)):

View File

@ -123,8 +123,19 @@ class PyobjMixin(object):
return self._fslineno
def reportinfo(self):
fspath, lineno = self._getfslineno()
modpath = self.getmodpath()
obj = self.obj
if hasattr(obj, 'compat_co_firstlineno'):
# nose compatibility
fspath = sys.modules[obj.__module__].__file__
if fspath.endswith(".pyc"):
fspath = fspath[:-1]
#assert 0
#fn = inspect.getsourcefile(obj) or inspect.getfile(obj)
lineno = obj.compat_co_firstlineno
modpath = obj.__module__
else:
fspath, lineno = self._getfslineno()
modpath = self.getmodpath()
return fspath, lineno, modpath
class PyCollectorMixin(PyobjMixin, pytest.collect.Collector):
@ -501,16 +512,16 @@ class Metafunc:
:arg funcargs: argument keyword dictionary used when invoking
the test function.
:arg id: used for reporting and identification purposes. If you
:arg id: used for reporting and identification purposes. If you
don't supply an `id` the length of the currently
list of calls to the test function will be used.
:arg param: will be exposed to a later funcarg factory invocation
through the ``request.param`` attribute. Setting it (instead of
directly providing a ``funcargs`` ditionary) is called
*indirect parametrization*. Indirect parametrization is
preferable if test values are expensive to setup or can
only be created after certain fixtures or test-run related
*indirect parametrization*. Indirect parametrization is
preferable if test values are expensive to setup or can
only be created after certain fixtures or test-run related
initialization code has been run.
"""
assert funcargs is None or isinstance(funcargs, dict)
@ -593,7 +604,7 @@ class FuncargRequest:
def applymarker(self, marker):
""" apply a marker to a single test function invocation.
This method is useful if you don't want to have a keyword/marker
on all function invocations.
on all function invocations.
:arg marker: a :py:class:`pytest.plugin.mark.MarkDecorator` object
created by a call to ``py.test.mark.NAME(...)``.

View File

@ -41,7 +41,7 @@ def getitemnodeinfo(item):
try:
return item._nodeinfo
except AttributeError:
location = item.ihook.pytest_report_iteminfo(item=item)
location = item.reportinfo()
location = (str(location[0]), location[1], str(location[2]))
nodenames = tuple(item.listnames())
nodeid = item.collection.getid(item)

View File

@ -116,9 +116,6 @@ def pytest_collect_directory(path, parent):
return
return Directory(path, parent=parent)
def pytest_report_iteminfo(item):
return item.reportinfo()
class Session(object):
class Interrupted(KeyboardInterrupt):
""" signals an interrupted test run. """

View File

@ -1061,18 +1061,6 @@ class TestReportInfo:
nodeinfo = runner.getitemnodeinfo(item)
assert nodeinfo.location == ("ABCDE", 42, "custom")
def test_itemreport_pytest_report_iteminfo(self, testdir, linecomp):
item = testdir.getitem("def test_func(): pass")
tup = "FGHJ", 42, "custom"
class Plugin:
def pytest_report_iteminfo(self, item):
return tup
item.config.pluginmanager.register(Plugin())
runner = runner = item.config.pluginmanager.getplugin("runner")
nodeinfo = runner.getitemnodeinfo(item)
location = nodeinfo.location
assert location == tup
def test_func_reportinfo(self, testdir):
item = testdir.getitem("def test_func(): pass")
fspath, lineno, modpath = item.reportinfo()

View File

@ -1,5 +1,4 @@
import py
from pytest.plugin.session import pytest_report_iteminfo
class SessionTests:
def test_basic_testitem_events(self, testdir):
@ -225,12 +224,3 @@ def test_exclude(testdir):
result = testdir.runpytest("--ignore=hello", "--ignore=hello2")
assert result.ret == 0
result.stdout.fnmatch_lines(["*1 passed*"])
def test_pytest_report_iteminfo():
class FakeItem(object):
def reportinfo(self):
return "-reportinfo-"
res = pytest_report_iteminfo(FakeItem())
assert res == "-reportinfo-"

View File

@ -96,7 +96,7 @@ class TestTerminal:
tr = TerminalReporter(item.config, file=linecomp.stringio)
item.config.pluginmanager.register(tr)
nodeid = item.collection.getid(item)
location = item.ihook.pytest_report_iteminfo(item=item)
location = item.reportinfo()
tr.config.hook.pytest_runtest_logstart(nodeid=nodeid,
location=location, fspath=str(item.fspath))
linecomp.assert_contains_lines([