Changeset 36

Show
Ignore:
Timestamp:
Mon May 8 21:05:04 2006
Author:
jpellerin
Message:

r934@Jason-Pellerins-Computer: jhp | 2006-05-06 13:28:16 -0500
Catch and loag plugin load errors
r935@Jason-Pellerins-Computer: jhp | 2006-05-07 17:17:07 -0500
Add test for plugins that fail to load
r936@Jason-Pellerins-Computer: jhp | 2006-05-08 21:03:02 -0500
Move profile plugin to nose.plugins.prof to avoid shadowing stdlib module profile.py

Files:

Legend:

Unmodified
Added
Removed
Modified
  • branches/0.9-stable/unit_tests/test_plugins.py

    r34 r36  
      1 import logging  
    1 2 import os  
    2 3 import sys  
     
    11 12 from nose.plugins.doctests import Doctest  
    12 13 from nose.plugins.missed import MissedTests  
    13   from nose.plugins.profile import Profile  
      14 from nose.plugins.prof import Profile  
    13 14  
    14 15 from mock import *  
     
    19 20     pass  
    20 21  
      22 class ErrPlugin(object):  
      23     def load(self):  
      24         raise Exception("Failed to load the plugin")  
      25      
      26 class ErrPkgResources(object):  
      27     def iter_entry_points(self, ep):  
      28         yield ErrPlugin()  
      29  
      30          
    21 31 # some plugins have 2.4-only features  
    22 32 pyvers = sys.version_info  
     
    44 54         for p in plugs:  
    45 55             assert not p.enabled  
    46                
      56  
      57     def test_failing_load(self):  
      58         tmp = nose.plugins.pkg_resources  
      59         nose.plugins.pkg_resources = ErrPkgResources()  
      60         try:  
      61             # turn off logging  
      62             lvl = logging.getLogger('nose.plugins').level  
      63             logging.getLogger('nose.plugins').setLevel(100)             
      64             plugs = list(nose.plugins.load_plugins(builtin=True, others=True))  
      65             self.assertEqual(plugs, [])  
      66         finally:  
      67             nose.plugins.pkg_resources = tmp  
      68             logging.getLogger('nose.plugins').setLevel(lvl)  
    47 69     def test_add_options(self):  
    48 70         conf = Config()  
  • branches/0.9-stable/nose/plugins/__init__.py

    r20 r36  
    132 132     for ep in pkg_resources.iter_entry_points('nose.plugins'):  
    133 133         log.debug("load plugin %s" % ep)  
    134           plug = ep.load()  
      134         try:  
      135             plug = ep.load()  
      136         except KeyboardInterrupt:  
      137             raise  
      138         except Exception, e:  
      139             # never want a plugin load to kill the test run  
      140             log.error("Unable to load plugin %s: %s", ep, e)  
      141             continue  
    135 142         if plug.__module__.startswith('nose.plugins'):  
    136 143             if builtin:  
  • branches/0.9-stable/setup.py

    r26 r36  
    37 37             'coverage = nose.plugins.cover:Coverage',  
    38 38             'doctest = nose.plugins.doctests:Doctest',  
    39               'profile = nose.plugins.profile:Profile',  
      39             'profile = nose.plugins.prof:Profile',  
    39 39             'attrib = nose.plugins.attrib:AttributeSelector',  
    40 40             'missed = nose.plugins.missed:MissedTests'