remove pytest_report_iteminfo hook, i strongly guess nobody needs or uses it.
This commit is contained in:
		
							parent
							
								
									28d51e26a0
								
							
						
					
					
						commit
						5251653fc3
					
				|  | @ -194,14 +194,6 @@ pytest_report_teststatus.firstresult = True | ||||||
| def pytest_terminal_summary(terminalreporter): | def pytest_terminal_summary(terminalreporter): | ||||||
|     """ add additional section in terminal summary reporting. """ |     """ 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 | # doctest hooks | ||||||
| # ------------------------------------------------------------------------- | # ------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | @ -49,19 +49,6 @@ def pytest_runtest_makereport(__multicall__, item, call): | ||||||
|             call2 = call.__class__(lambda: py.test.skip(str(call.excinfo.value)), call.when) |             call2 = call.__class__(lambda: py.test.skip(str(call.excinfo.value)), call.when) | ||||||
|             call.excinfo = call2.excinfo |             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): | def pytest_runtest_setup(item): | ||||||
|     if isinstance(item, (py.test.collect.Function)): |     if isinstance(item, (py.test.collect.Function)): | ||||||
|  |  | ||||||
|  | @ -123,8 +123,19 @@ class PyobjMixin(object): | ||||||
|         return self._fslineno |         return self._fslineno | ||||||
| 
 | 
 | ||||||
|     def reportinfo(self): |     def reportinfo(self): | ||||||
|         fspath, lineno = self._getfslineno() |         obj = self.obj | ||||||
|         modpath = self.getmodpath() |         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 |         return fspath, lineno, modpath | ||||||
| 
 | 
 | ||||||
| class PyCollectorMixin(PyobjMixin, pytest.collect.Collector): | class PyCollectorMixin(PyobjMixin, pytest.collect.Collector): | ||||||
|  |  | ||||||
|  | @ -41,7 +41,7 @@ def getitemnodeinfo(item): | ||||||
|     try: |     try: | ||||||
|         return item._nodeinfo |         return item._nodeinfo | ||||||
|     except AttributeError: |     except AttributeError: | ||||||
|         location = item.ihook.pytest_report_iteminfo(item=item) |         location = item.reportinfo() | ||||||
|         location = (str(location[0]), location[1], str(location[2])) |         location = (str(location[0]), location[1], str(location[2])) | ||||||
|         nodenames = tuple(item.listnames()) |         nodenames = tuple(item.listnames()) | ||||||
|         nodeid = item.collection.getid(item) |         nodeid = item.collection.getid(item) | ||||||
|  |  | ||||||
|  | @ -116,9 +116,6 @@ def pytest_collect_directory(path, parent): | ||||||
|             return |             return | ||||||
|     return Directory(path, parent=parent) |     return Directory(path, parent=parent) | ||||||
| 
 | 
 | ||||||
| def pytest_report_iteminfo(item): |  | ||||||
|     return item.reportinfo() |  | ||||||
| 
 |  | ||||||
| class Session(object): | class Session(object): | ||||||
|     class Interrupted(KeyboardInterrupt): |     class Interrupted(KeyboardInterrupt): | ||||||
|         """ signals an interrupted test run. """ |         """ signals an interrupted test run. """ | ||||||
|  |  | ||||||
|  | @ -1061,18 +1061,6 @@ class TestReportInfo: | ||||||
|         nodeinfo = runner.getitemnodeinfo(item) |         nodeinfo = runner.getitemnodeinfo(item) | ||||||
|         assert nodeinfo.location == ("ABCDE", 42, "custom") |         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): |     def test_func_reportinfo(self, testdir): | ||||||
|         item = testdir.getitem("def test_func(): pass") |         item = testdir.getitem("def test_func(): pass") | ||||||
|         fspath, lineno, modpath = item.reportinfo() |         fspath, lineno, modpath = item.reportinfo() | ||||||
|  |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| import py | import py | ||||||
| from pytest.plugin.session import pytest_report_iteminfo |  | ||||||
| 
 | 
 | ||||||
| class SessionTests: | class SessionTests: | ||||||
|     def test_basic_testitem_events(self, testdir): |     def test_basic_testitem_events(self, testdir): | ||||||
|  | @ -225,12 +224,3 @@ def test_exclude(testdir): | ||||||
|     result = testdir.runpytest("--ignore=hello", "--ignore=hello2") |     result = testdir.runpytest("--ignore=hello", "--ignore=hello2") | ||||||
|     assert result.ret == 0 |     assert result.ret == 0 | ||||||
|     result.stdout.fnmatch_lines(["*1 passed*"]) |     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-" |  | ||||||
|  |  | ||||||
|  | @ -96,7 +96,7 @@ class TestTerminal: | ||||||
|         tr = TerminalReporter(item.config, file=linecomp.stringio) |         tr = TerminalReporter(item.config, file=linecomp.stringio) | ||||||
|         item.config.pluginmanager.register(tr) |         item.config.pluginmanager.register(tr) | ||||||
|         nodeid = item.collection.getid(item) |         nodeid = item.collection.getid(item) | ||||||
|         location = item.ihook.pytest_report_iteminfo(item=item) |         location = item.reportinfo() | ||||||
|         tr.config.hook.pytest_runtest_logstart(nodeid=nodeid, |         tr.config.hook.pytest_runtest_logstart(nodeid=nodeid, | ||||||
|             location=location, fspath=str(item.fspath)) |             location=location, fspath=str(item.fspath)) | ||||||
|         linecomp.assert_contains_lines([ |         linecomp.assert_contains_lines([ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue