# HG changeset patch -- Bitbucket.org
# Project pytest
# URL http://bitbucket.org/hpk42/pytest/overview
# User holger krekel <hol...@merlinux.eu>
# Date 1288909283 -3600
# Node ID 2dfb0db0864d075300712366a86cdf642c7c68d9
# Parent  3253d770b03c29b46f2d5c96f46b00b01f882551
remove pytest_report_iteminfo hook, i strongly guess nobody needs or uses it.

--- a/testing/plugin/test_python.py
+++ b/testing/plugin/test_python.py
@@ -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()

--- a/pytest/plugin/nose.py
+++ b/pytest/plugin/nose.py
@@ -49,19 +49,6 @@ def pytest_runtest_makereport(__multical
             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)):

--- a/pytest/plugin/python.py
+++ b/pytest/plugin/python.py
@@ -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(...)``.

--- a/pytest/hookspec.py
+++ b/pytest/hookspec.py
@@ -20,7 +20,7 @@ def pytest_cmdline_parse(pluginmanager, 
 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 = T
 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
 # -------------------------------------------------------------------------

--- a/pytest/plugin/session.py
+++ b/pytest/plugin/session.py
@@ -116,9 +116,6 @@ def pytest_collect_directory(path, paren
             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. """

--- a/testing/plugin/test_terminal.py
+++ b/testing/plugin/test_terminal.py
@@ -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([

--- a/pytest/plugin/runner.py
+++ b/pytest/plugin/runner.py
@@ -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)

--- a/testing/plugin/test_session.py
+++ b/testing/plugin/test_session.py
@@ -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-"
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to