shrink and merge the somewhat obscure and undocumented internal hinting
system with the new warnings one
This commit is contained in:
parent
24db492f53
commit
ebd10aa6b4
|
@ -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())
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue