Changeset 102
- Timestamp:
- Tue Oct 10 15:56:49 2006
- Files:
-
- trunk/unit_tests/test_plugins.py (modified) (diff)
- trunk/nose/plugins/doctests.py (modified) (diff)
- trunk/nose/plugins/__init__.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/unit_tests/test_plugins.py
r96 r102 6 6 from optparse import OptionParser 7 7 import tempfile 8 from warnings import warn 8 from warnings import warn, filterwarnings, resetwarnings 8 8 9 9 from nose.config import Config … … 61 61 nose.plugins.pkg_resources = ErrPkgResources() 62 62 try: 63 # turn off logging 64 lvl = logging.getLogger('nose.plugins').level 65 logging.getLogger('nose.plugins').setLevel(100) 63 # turn off warnings 64 filterwarnings('ignore', category=RuntimeWarning) 66 65 plugs = list(nose.plugins.load_plugins(builtin=True, others=True)) 67 66 self.assertEqual(plugs, []) 68 67 finally: 69 68 nose.plugins.pkg_resources = tmp 70 logging.getLogger('nose.plugins').setLevel(lvl)69 resetwarnings() 70 69 71 70 def test_add_options(self): … … 117 116 else: 118 117 assert len(parser.opts) == 2 119 118 119 def test_config(self): 120 # test that configuration works properly when both environment 121 # and command line specify a doctest extension 122 parser = OptionParser() 123 env = {'NOSE_DOCTEST_EXTENSION':'ext'} 124 argv = ['--doctest-extension', 'txt'] 125 dtp = Doctest() 126 dtp.add_options(parser, env) 127 options, args = parser.parse_args(argv) 128 129 print options 130 print args 131 self.assertEqual(options.doctestExtension, ['ext', 'txt']) 132 133 env = {} 134 parser = OptionParser() 135 dtp.add_options(parser, env) 136 options, args = parser.parse_args(argv) 137 print options 138 print args 139 self.assertEqual(options.doctestExtension, ['txt']) 140 120 141 def test_want_file(self): 121 142 # doctest plugin can select module and/or non-module files -
trunk/nose/plugins/doctests.py
r89 r102 41 41 parser.add_option('--doctest-extension', action="append", 42 42 dest="doctestExtension", 43 default=env.get('NOSE_DOCTEST_EXTENSION'),44 43 help="Also look for doctests in files with " 45 44 "this extension [NOSE_DOCTEST_EXTENSION]") 45 # Set the default as a list, if given in env; otherwise 46 # an additional value set on the command line will cause 47 # an error. 48 env_setting = env.get('NOSE_DOCTEST_EXTENSION') 49 if env_setting is not None: 50 parser.set_defaults(doctestExtension=tolist(env_setting)) 46 51 except AttributeError: 47 52 pass -
trunk/nose/plugins/__init__.py
r98 r102 141 141 # but we can't log here because the logger is not yet 142 142 # configured 143 warn("Unable to load plugin %s: %s" % (ep, e)) 143 warn("Unable to load plugin %s: %s" % (ep, e), RuntimeWarning) 143 143 continue 144 144 if plug.__module__.startswith('nose.plugins'):
