diff --git a/_pytest/config.py b/_pytest/config.py index 8ac5d1a1b..c22716bb3 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -82,6 +82,9 @@ class PytestPluginManager(PluginManager): config.addinivalue_line("markers", "trylast: mark a hook implementation function such that the " "plugin machinery will try to call it last/as late as possible.") + while self._warnings: + warning = self._warnings.pop(0) + config.warn(code="I1", message=warning) class Parser: @@ -94,7 +97,6 @@ class Parser: self._usage = usage self._inidict = {} self._ininames = [] - self.hints = [] def processoption(self, option): if self._processopt: @@ -379,14 +381,6 @@ class MyOptionParser(py.std.argparse.ArgumentParser): py.std.argparse.ArgumentParser.__init__(self, usage=parser._usage, add_help=False, formatter_class=DropShorterLongHelpFormatter) - def format_epilog(self, formatter): - hints = self._parser.hints - if hints: - s = "\n".join(["hint: " + x for x in hints]) + "\n" - s = "\n" + s + "\n" - return s - return "" - def parse_args(self, args=None, namespace=None): """allow splitting of positional arguments""" args, argv = self.parse_known_args(args, namespace) @@ -716,7 +710,6 @@ class Config(object): self._preparse(args) # XXX deprecated hook: self.hook.pytest_cmdline_preparse(config=self, args=args) - self._parser.hints.extend(self.pluginmanager._hints) args = self._parser.parse_setoption(args, self.option) if not args: args.append(py.std.os.getcwd()) diff --git a/_pytest/core.py b/_pytest/core.py index d029e7223..43d2801c0 100644 --- a/_pytest/core.py +++ b/_pytest/core.py @@ -71,7 +71,7 @@ class PluginManager(object): self._name2plugin = {} self._listattrcache = {} self._plugins = [] - self._hints = [] + self._warnings = [] self.trace = TagTracer().get("pluginmanage") self._plugin_distinfo = [] self._shutdown = [] @@ -225,7 +225,7 @@ class PluginManager(object): raise elif not isinstance(e, py.test.skip.Exception): raise - self._hints.append("skipped plugin %r: %s" %((modname, e.msg))) + self._warnings.append("skipped plugin %r: %s" %((modname, e.msg))) else: self.register(mod, modname) self.consider_module(mod) diff --git a/_pytest/helpconfig.py b/_pytest/helpconfig.py index 1fef7eb3f..9e31c21e7 100644 --- a/_pytest/helpconfig.py +++ b/_pytest/helpconfig.py @@ -64,7 +64,6 @@ def pytest_cmdline_main(config): def showhelp(config): tw = py.io.TerminalWriter() tw.write(config._parser.optparser.format_help()) - tw.write(config._parser.optparser.format_epilog(None)) tw.line() tw.line() #tw.sep( "=", "config file settings") @@ -86,6 +85,8 @@ def showhelp(config): tw.line("to see available fixtures type: py.test --fixtures") tw.line("(shown according to specified file_or_dir or current dir " "if not specified)") + for warning in config.pluginmanager._warnings: + tw.line("warning: %s" % (warning,)) return tw.line("conftest.py options:") diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 4e73e40df..9b64ba336 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -348,7 +348,6 @@ class TerminalReporter: if exitstatus in (0, 1, 2, 4): self.summary_errors() self.summary_failures() - self.summary_hints() self.summary_warnings() self.config.hook.pytest_terminal_summary(terminalreporter=self) if exitstatus == 2: @@ -415,11 +414,6 @@ class TerminalReporter: l.append(x) return l - def summary_hints(self): - if self.config.option.traceconfig: - for hint in self.config.pluginmanager._hints: - self._tw.line("hint: %s" % hint) - def summary_warnings(self): if self.hasopt("w"): warnings = self.stats.get("warnings") diff --git a/testing/test_core.py b/testing/test_core.py index 071a6c264..7ec8d6519 100644 --- a/testing/test_core.py +++ b/testing/test_core.py @@ -43,11 +43,11 @@ class TestBootstrapping: """) p.copy(p.dirpath("skipping2.py")) monkeypatch.setenv("PYTEST_PLUGINS", "skipping2") - result = testdir.runpytest("-p", "skipping1", "--traceconfig") + result = testdir.runpytest("-rw", "-p", "skipping1", "--traceconfig") assert result.ret == 0 result.stdout.fnmatch_lines([ - "*hint*skipping1*hello*", - "*hint*skipping2*hello*", + "WI1*skipped plugin*skipping1*hello*", + "WI1*skipped plugin*skipping2*hello*", ]) def test_consider_env_plugin_instantiation(self, testdir, monkeypatch): diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index fc09bee7c..4b3a71475 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -236,16 +236,6 @@ class TestParser: help = parser.optparser.format_help() assert '-doit, --func-args foo' in help -@pytest.mark.skipif("sys.version_info < (2,5)") -def test_addoption_parser_epilog(testdir): - testdir.makeconftest(""" - def pytest_addoption(parser): - parser.hints.append("hello world") - parser.hints.append("from me too") - """) - result = testdir.runpytest('--help') - #assert result.ret != 0 - result.stdout.fnmatch_lines(["hint: hello world", "hint: from me too"]) @pytest.mark.skipif("sys.version_info < (2,6)") def test_argcomplete(testdir, monkeypatch):