reverse options ordering in Parser class instead of on PluginManager

This commit is contained in:
holger krekel 2010-11-05 23:37:31 +01:00
parent bb732a4e75
commit 99dfb8ad65
2 changed files with 3 additions and 8 deletions

View File

@ -180,11 +180,6 @@ class PluginManager(object):
for hint in self._hints: for hint in self._hints:
tw.line("hint: %s" % hint) tw.line("hint: %s" % hint)
def do_addoption(self, parser):
mname = "pytest_addoption"
methods = reversed(self.listattr(mname))
MultiCall(methods, {'parser': parser}).execute()
def do_configure(self, config): def do_configure(self, config):
assert not hasattr(self, '_config') assert not hasattr(self, '_config')
self._config = config self._config = config

View File

@ -53,12 +53,12 @@ class Parser:
def parse(self, args): def parse(self, args):
self.optparser = optparser = MyOptionParser(self) self.optparser = optparser = MyOptionParser(self)
groups = self._groups + [self._anonymous] groups = list(reversed(self._groups)) + [self._anonymous]
for group in groups: for group in groups:
if group.options: if group.options:
desc = group.description or group.name desc = group.description or group.name
optgroup = py.std.optparse.OptionGroup(optparser, desc) optgroup = py.std.optparse.OptionGroup(optparser, desc)
optgroup.add_options(group.options) optgroup.add_options(reversed(group.options))
optparser.add_option_group(optgroup) optparser.add_option_group(optgroup)
return self.optparser.parse_args([str(x) for x in args]) return self.optparser.parse_args([str(x) for x in args])
@ -304,7 +304,7 @@ class Config(object):
self.pluginmanager.consider_env() self.pluginmanager.consider_env()
self.pluginmanager.consider_preparse(args) self.pluginmanager.consider_preparse(args)
self._setinitialconftest(args) self._setinitialconftest(args)
self.pluginmanager.do_addoption(self._parser) self.hook.pytest_addoption(parser=self._parser)
def _checkversion(self): def _checkversion(self):
minver = self.inicfg.get('minversion', None) minver = self.inicfg.get('minversion', None)