Jason Pellerin avatar Jason Pellerin committed 1ba7abf

* Bumped version to 0.9.3
* Made builtin plugins load directly, not through entry points
* Added comment to doctest plugin where a fix is needed

Comments (0)

Files changed (5)

 from nose.util import file_like, split_test_name, test_address
 
 __author__ = 'Jason Pellerin'
-__versioninfo__ = (0, 9, 2)
+__versioninfo__ = (0, 9, 3)
 __version__ = '.'.join(map(str, __versioninfo__))
 
 __all__ = [ 

nose/plugins/__init__.py

 
 import logging
 import pkg_resources
+from inspect import isclass
 from warnings import warn
 from nose.plugins.base import *
 
+builtin_plugins = ('attrib', 'cover', 'doctests', 'isolate', 'missed', 'prof')
 log = logging.getLogger(__name__)
 
 def call_plugins(plugins, method, *arg, **kw):
 def load_plugins(builtin=True, others=True):
     """Load plugins, either builtin, others, or both.
     """
+    loaded = []
+    if builtin:
+        for name in builtin_plugins:
+            try:
+                parent = __import__(__name__, globals(), locals(), [name])
+                pmod = getattr(parent, name)
+                for entry in dir(pmod):
+                    obj = getattr(pmod, entry)
+                    if (isclass(obj)
+                        and issubclass(obj, Plugin)
+                        and obj is not Plugin
+                        and not obj in loaded):
+                        log.debug("load builtin plugin %s (%s)" % (name, obj))
+                        yield obj
+                        loaded.append(obj)
+            except KeyboardInterrupt:
+                raise
+            except Exception, e:
+                warn("Unable to load builtin plugin %s: %s" % (name, e),
+                     RuntimeWarning)
+    if not others:
+        return
     for ep in pkg_resources.iter_entry_points('nose.plugins'):
         log.debug("load plugin %s" % ep)
         try:
             warn("Unable to load plugin %s: %s" % (ep, e), RuntimeWarning)
             continue
         if plug.__module__.startswith('nose.plugins'):
-            if builtin:
-                yield plug
-        elif others:
+            # already loaded as a builtin
+            pass
+        elif plug not in loaded:
             yield plug
+            loaded.append(plug)
 
 

nose/plugins/doctests.py

         try:
             doctests = doctest.DocTestSuite(module)
         except ValueError:
+            # FIXME this doesn't mean "no tests" it means "unable to load
+            # tests" -- it should be returned as a pseudo-suite that
+            # has a single 'test' that re-raises the exception
             log.debug("No doctests in %s", module)
             return
         else:
         'console_scripts': [
             'nosetests = nose:run_exit'
             ],
-        'nose.plugins': [
-            'coverage = nose.plugins.cover:Coverage',
-            'doctest = nose.plugins.doctests:Doctest',
-            'profile = nose.plugins.prof:Profile',
-            'attrib = nose.plugins.attrib:AttributeSelector',
-            'missed = nose.plugins.missed:MissedTests',
-            'isolation = nose.plugins.isolate:IsolationPlugin'
-            ],
         'distutils.commands': [
             ' nosetests = nose.commands:nosetests'
             ],

unit_tests/test_plugins.py

     def test_failing_load(self):
         tmp = nose.plugins.pkg_resources
         nose.plugins.pkg_resources = ErrPkgResources()
+        class Dummy:
+            pass
+        nose.plugins.Plugin = Dummy
         try:
             # turn off warnings
             filterwarnings('ignore', category=RuntimeWarning)
             self.assertEqual(plugs, [])
         finally:
             nose.plugins.pkg_resources = tmp
+            nose.plugins.Plugin = Plugin
             resetwarnings()
             
     def test_add_options(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.