Commits

Anonymous committed 0ba5d44

Fixed issue with 2.7 and plugin testName call

Comments (0)

Files changed (4)

 _env
 doc/.build
 dist
-build
+build
+.noseids

functional_tests/test_plugins.py

              'loadTestsFromDir', 'afterDirectory',
              'report', 'finalize'])
 
-    def test_plugin_calls_package1_versbose(self):
+    def test_plugin_calls_package1_verbose(self):
         wdir = os.path.join(support, 'package1')
         man = RecordingPluginManager()
         conf = Config(plugins=man, stream=sys.stdout)
              'makeTest', 'wantMethod', 'loadTestsFromTestClass',
              'loadTestsFromTestCase', 'loadTestsFromModule', 'startContext',
              'beforeTest', 'prepareTestCase', 'startTest', 'describeTest',
-             'addSuccess', 'stopTest', 'afterTest', 'stopContext', 'testName',
+             'testName', 'addSuccess', 'stopTest', 'afterTest', 'stopContext',
              'afterContext', 'loadTestsFromDir', 'afterDirectory',
-             'report', 'finalize'])        
+             'report', 'finalize'])
 
 
 
         self.plugins = config.plugins
         self.passed = None
         unittest.TestCase.__init__(self)
-        
+
     def __call__(self, *arg, **kwarg):
         return self.run(*arg, **kwarg)
 
 
     def exc_info(self):
         """Extract exception info.
-        """        
+        """
         exc, exv, tb = sys.exc_info()
         return (exc, exv, tb)
-        
+
     def id(self):
         """Get a short(er) description of the test
         """
             return resolve_name(self.test.__module__)
         except AttributeError:
             pass
-        return None                
+        return None
     context = property(_context, None, None,
                       """Get the context object of this test (if any).""")
-    
+
     def run(self, result):
         """Modified run for the test wrapper.
 
                 result.addError(self, err)
         finally:
             self.afterTest(result)
-        
+
     def runTest(self, result):
         """Run the test. Plugins may alter the test by returning a
         value from prepareTestCase. The value must be callable and
         must accept one argument, the result instance.
-        """        
+        """
         test = self.test
         plug_test = self.config.plugins.prepareTestCase(self)
         if plug_test is not None:
                     test._TestCase__testMethodDoc.strip()
             except AttributeError:
                 pass
-        return self.test.shortDescription()
+        # 2.7 compat: shortDescription() always returns something
+        # which is a change from 2.6 and below, and breaks the
+        # testName plugin call.
+        desc = self.test.shortDescription()
+        if desc == str(self.test):
+            return
+        return desc
 
 
 class TestBase(unittest.TestCase):
     """Common functionality for FunctionTestCase and MethodTestCase.
     """
     __test__ = False # do not collect
-    
+
     def id(self):
         return str(self)
-        
+
     def runTest(self):
         self.test(*self.arg)
-    
+
     def shortDescription(self):
         if hasattr(self.test, 'description'):
             return self.test.description
             doc = str(self)
         return doc.strip().split("\n")[0].strip()
 
-    
+
 class FunctionTestCase(TestBase):
     """TestCase wrapper for test functions.
 
     create test cases for test functions.
     """
     __test__ = False # do not collect
-    
+
     def __init__(self, test, setUp=None, tearDown=None, arg=tuple(),
                  descriptor=None):
         """Initialize the MethodTestCase.
         * descriptor -- the function, other than the test, that should be used
           to construct the test name. This is to support generator functions.
         """
-        
+
         self.test = test
         self.setUpFunc = setUp
         self.tearDownFunc = tearDown
         self.arg = arg
         self.descriptor = descriptor
-        TestBase.__init__(self)        
+        TestBase.__init__(self)
 
     def address(self):
         """Return a round-trip name for this test, a name that can be
         if self.descriptor is not None:
             return test_address(self.descriptor)
         else:
-            return test_address(self.test)    
+            return test_address(self.test)
 
     def _context(self):
         return resolve_name(self.test.__module__)
     context = property(_context, None, None,
                       """Get context (module) of this test""")
-        
+
     def setUp(self):
         """Run any setup function attached to the test function
         """
         else:
             names = ('teardown', 'tearDown', 'tearDownFunc')
             try_run(self.test, names)
-        
+
     def __str__(self):
         func, arg = self._descriptors()
         if hasattr(func, 'compat_func_name'):
         # FIXME need to include the full dir path to disambiguate
         # in cases where test module of the same name was seen in
         # another directory (old fromDirectory)
-        return name 
+        return name
     __repr__ = __str__
-    
+
     def _descriptors(self):
         """Get the descriptors of the test function: the function and
         arguments that will be used to construct the test name. In
         """
         if self.descriptor:
             return self.descriptor, self.arg
-        else:            
+        else:
             return self.test, self.arg
 
 
     create test cases for test methods.
     """
     __test__ = False # do not collect
-    
+
     def __init__(self, method, test=None, arg=tuple(), descriptor=None):
         """Initialize the MethodTestCase.
 
         self.inst = self.cls()
         if self.test is None:
             method_name = self.method.__name__
-            self.test = getattr(self.inst, method_name)            
+            self.test = getattr(self.inst, method_name)
         TestBase.__init__(self)
 
     def __str__(self):
 
     def tearDown(self):
         try_run(self.inst, ('teardown', 'tearDown'))
-        
+
     def _descriptors(self):
         """Get the descriptors of the test method: the method and
         arguments that will be used to construct the test name. In

nose/plugins/skip.py

 the exception will not be counted as an error or failure. This plugin
 is enabled by default but may be disabled with the ``--no-skip`` option.
 """
-    
+
 from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
 
 
         disable = getattr(options, 'noSkip', False)
         if disable:
             self.enabled = False
-            
+