diff options
author | Daniel Lepage <dplepage@gmail.com> | 2014-08-10 10:53:40 -0400 |
---|---|---|
committer | Daniel Lepage <dplepage@gmail.com> | 2014-08-10 10:53:40 -0400 |
commit | 8f5d025a1f7bcf6256c0022c044dee5101646404 (patch) | |
tree | 954829278f676f0edea25cc0fa4534d98fea0e10 | |
parent | ac9cc08e1a95e5614c8f9863091014186edecbdd (diff) | |
download | nose-8f5d025a1f7bcf6256c0022c044dee5101646404.tar.gz |
Recognize doctest options defined in other plugins.
-rw-r--r-- | nose/plugins/doctests.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/nose/plugins/doctests.py b/nose/plugins/doctests.py index c561a47..5ef6579 100644 --- a/nose/plugins/doctests.py +++ b/nose/plugins/doctests.py @@ -195,18 +195,19 @@ class Doctest(Plugin): if options.doctestOptions: flags = ",".join(options.doctestOptions).split(',') for flag in flags: - try: - if flag.startswith('+'): - self.optionflags |= getattr(doctest, flag[1:]) - elif flag.startswith('-'): - self.optionflags &= ~getattr(doctest, flag[1:]) - else: - raise ValueError( - "Must specify doctest options with starting " + - "'+' or '-'. Got %s" % (flag,)) - except AttributeError: + if not flag or flag[0] not in '+-': + raise ValueError( + "Must specify doctest options with starting " + + "'+' or '-'. Got %s" % (flag,)) + mode, option_name = flag[0], flag[1:] + option_flag = doctest.OPTIONFLAGS_BY_NAME.get(option_name) + if not option_flag: raise ValueError("Unknown doctest option %s" % - (flag[1:],)) + (option_name,)) + if mode == '+': + self.optionflags |= option_flag + elif mode == '-': + self.optionflags &= ~option_flag def prepareTestLoader(self, loader): """Capture loader's suiteClass. |