diff options
author | John Szakmeister <john@szakmeister.net> | 2014-08-11 06:17:13 -0400 |
---|---|---|
committer | John Szakmeister <john@szakmeister.net> | 2014-08-11 06:17:13 -0400 |
commit | 9e9adc50699862db40a6e288719eedd45ba6ad9d (patch) | |
tree | 6207189e83d395f6b5872097d41c243e235c4de5 /nose | |
parent | a48973ebab9dde0135d670a6a276e6e0938e8ba2 (diff) | |
parent | 8f5d025a1f7bcf6256c0022c044dee5101646404 (diff) | |
download | nose-9e9adc50699862db40a6e288719eedd45ba6ad9d.tar.gz |
Merge pull request #798 from dplepage/master
Recognize doctest options defined in other plugins.
Diffstat (limited to 'nose')
-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. |