Changeset 26

Show
Ignore:
Timestamp:
Sun Apr 23 18:53:25 2006
Author:
jpellerin
Message:
  • Disable attr plugin eval option for python 2.3 (#44)
  • Don't use super() (#46)
  • Ignore root logger settings and don't propagate messages (#48)
  • Add doc->wiki script, still needs some fine-tuning. (#4)


Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/setup.py

    r18 r26  
    42 42             ]  
    43 43         },  
    44       test_suite = 'selftest.suite',  
      44     test_suite = 'nose.collector',  
    44 44     classifiers = [  
    45 45         'Development Status :: 4 - Beta',  
  • trunk/unit_tests/test_plugin_interfaces.py

    r21 r26  
    1 1 import unittest  
    2   from nose.plugins.base import PluginInterface  
      2 from nose.plugins.base import IPluginInterface  
    2 2  
    3 3 class TestPluginInterfaces(unittest.TestCase):  
     
    25 25         expect = selfuncs + loadfuncs + others  
    26 26          
    27           pd = dir(PluginInterface)  
      27         pd = dir(IPluginInterface)  
    27 27          
    28 28         for f in expect:  
    29               assert f in pd, "No %s in PluginInterface" % f  
    30               assert getattr(PluginInterface, f).__doc__, \  
    31                   "No docs for %f in PluginInterface" % f  
      29             assert f in pd, "No %s in IPluginInterface" % f  
      30             assert getattr(IPluginInterface, f).__doc__, \  
      31                 "No docs for %f in IPluginInterface" % f  
    32 32              
    33 33     def test_no_instantiate(self):  
    34 34         try:  
    35               p = PluginInterface()  
      35             p = IPluginInterface()  
    35 35         except TypeError:  
    36 36             pass  
    37 37         else:  
    38 38             assert False, \  
    39                   "Should not be able to instantiate PluginInterface"  
      39                 "Should not be able to instantiate IPluginInterface"  
    39 39              
    40 40 if __name__ == '__main__':  
  • trunk/unit_tests/test_proxy.py

    r21 r26  
    1 1 import sys  
    2 2 import unittest  
    3   import nose.result  
    4 3 from nose.config import Config  
    5 4 from nose.proxy import *  
      5 from nose.result import Result, start_capture, end_capture  
      6  
    6 7  
    7 8 class dummy:  
     
    36 37          
    37 38     def setUp(self):  
    38           nose.result.start_capture()  
      39         self.real_conf = Result.conf  
      40         start_capture()  
    39 41          
    40 42     def tearDown(self):  
    41           ResultProxy.conf = None  
    42           nose.result.end_capture()  
      43         Result.conf = self.real_conf  
      44         end_capture()  
    43 45  
    44 46     def test_proxy_result(self):  
    45 47         # set up configuration at class level  
    46           ResultProxy.conf = Config()  
      48         Result.conf = Config()  
    46 48          
    47 49         res = unittest.TestResult()  
     
    84 86         c.capture = True  
    85 87         c.detailedErrors = True  
    86           ResultProxy.conf = c  
      88         Result.conf = c  
    86 88          
    87 89         res = unittest.TestResult()  
     
    109 111         c.capture = True  
    110 112         c.detailedErrors = True  
    111           ResultProxy.conf = c  
      113         Result.conf = c  
    111 113          
    112 114         errcase = TestProxy(self.ErrTC('test_err'))  
     
    135 137         c.capture = True  
    136 138         c.detailedErrors = True  
    137           ResultProxy.conf = c  
      139         Result.conf = c  
    137 139          
    138 140         errcase = TestProxy(self.ErrTC('test_err'))  
  • trunk/unit_tests/test_plugins.py

    r24 r26  
    173 173                    {'dest': 'attr', 'action': 'append', 'default': None,  
    174 174                     'help': 'Run only tests that have attributes '  
    175                       'specified by ATTR [NOSE_ATTR]'}),  
    176                     (('-A', '--eval-attr'),  
    177                      {'dest': 'eval_attr', 'action': 'append',  
    178                       'default': None, 'metavar': 'EXPR',  
    179                       'help': 'Run only tests for whose attributes the '  
    180                       'Python expression EXPR evaluates to True '  
    181                       '[NOSE_EVAL_ATTR]'})]  
      175                     'specified by ATTR [NOSE_ATTR]'})]  
      176  
      177         if compat_24:  
      178             expect.append(  
      179                 (('-A', '--eval-attr'),  
      180                  {'dest': 'eval_attr', 'action': 'append',  
      181                   'default': None, 'metavar': 'EXPR',  
      182                   'help': 'Run only tests for whose attributes the '  
      183                   'Python expression EXPR evaluates to True '  
      184                   '[NOSE_EVAL_ATTR]'}))  
    182 185         self.assertEqual(parser.opts, expect)  
    183 186  
     
    194 197                                         ('weird', '66')])  
    195 198  
    196           opt.attr = None  
    197           opt.eval_attr = [ 'weird >= 66' ]  
    198           plug.configure(opt, Config())  
    199           self.assertEqual(plug.attribs[0][0], 'weird >= 66')  
    200           assert callable(plug.attribs[0][1])  
      199         if compat_24:  
      200             opt.attr = None  
      201             opt.eval_attr = [ 'weird >= 66' ]  
      202             plug.configure(opt, Config())  
      203             self.assertEqual(plug.attribs[0][0], 'weird >= 66')  
      204             assert callable(plug.attribs[0][1])  
    201 205                          
    202 206     def test_basic_attr(self):  
  • trunk/nose/core.py

    r23 r26  
    13 13 from nose.config import Config  
    14 14 from nose.loader import defaultTestLoader  
    15   from nose.proxy import ResultProxy, ResultProxySuite  
      15 from nose.proxy import ResultProxySuite  
      16 from nose.result import Result  
    16 17 from nose.selector import defaultSelector  
    17 18 from nose.suite import LazySuite  
     
    60 61     # FIXME somehow restrict plugin methods  
    61 62     conf = configure(env=os.environ)  
    62       ResultProxy.conf = conf  
      63     Result.conf = conf  
    62 63     loader = defaultTestLoader(conf)  
    63 64     loader.suiteClass = ResultProxySuite  
     
    74 75     def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1,  
    75 76                  conf=None):  
    76           super(TextTestRunner, self).__init__(stream, descriptions, verbosity)  
      77         unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity)  
    76 77         self.conf = conf  
    77 78      
     
    94 95             self.stream = wrapped  
    95 96              
    96           result = super(TextTestRunner, self).run(test)  
      97         result = unittest.TextTestRunner.run(self, test)  
    96 97         call_plugins(self.conf.plugins, 'finalize', result)  
    97 98         return result  
     
    359 360  
    360 361 def configure_logging(options):  
    361       loggers = [ '', 'nose', 'nose.case', 'nose.core', 'nose.importer',  
    362                   'nose.inspector', 'nose.loader', 'nose.plugins', 'nose.result',  
    363                   'nose.selector', 'nose.suite' ]  
    364    
    365       # output  
    366       if options.debug_log:  
    367           format = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')  
    368           handler = logging.FileHandler(options.debug_log)  
    369           handler.setFormatter(format)  
    370           logging.getLogger('').addHandler(handler)  
    371       else:  
    372           logging.basicConfig()  
      362     logger = logging.getLogger('nose')  
      363     logger.propagate = 0  
    373 364  
      365     # only add our default handler if there isn't already one there  
      366     # this avoids annoying duplicate log messages.  
      367     if not logger.handlers:  
      368         format = logging.Formatter('%(name)s: %(levelname)s: %(message)s')  
      369         if options.debug_log:  
      370             handler = logging.FileHandler(options.debug_log)  
      371         else:  
      372             handler = logging.StreamHandler(sys.stderr) # FIXME         
      373         handler.setFormatter(format)  
      374         logger.addHandler(handler)  
      375          
      376     # default level     
    374 377     lvl = logging.WARNING  
    375 378     if options.verbosity >= 5:  
     
    379 382     elif options.verbosity >= 3:  
    380 383         lvl = logging.INFO  
    381                    
    382       logging.getLogger('').setLevel(lvl)  
      384     logger.setLevel(lvl)  
    383 385          
    384 386     # individual overrides  
    385 387     if options.debug:  
    386 388         debug_loggers = options.debug.split(',')  
    387           for logger in debug_loggers:  
    388               l = logging.getLogger(logger)  
      389         for logger_name in debug_loggers:  
      390             l = logging.getLogger(logger_name)  
    389 391             l.setLevel(logging.DEBUG)  
    390 392              
  • trunk/nose/suite.py

    r24 r26  
    94 94     def __init__(self, loadtests, conf, cls):  
    95 95         self.cls = cls  
    96           super(TestClass, self).__init__(loadtests, conf)  
      96         LazySuite.__init__(self, loadtests, conf)  
    96 96  
    97 97     def __str__(self):  
     
    114 114         self.module = module  
    115 115         self.importPath = importPath  
    116           super(TestDir, self).__init__(loadtests, conf)  
      116         LazySuite.__init__(self, loadtests, conf)  
    116 116  
    117 117     def __repr__(self):  
     
    151 151         if module and moduleName is None:  
    152 152             self.moduleName = module.__name__         
    153           super(TestModule, self).__init__(loadtests, conf)  
      153         LazySuite.__init__(self, loadtests, conf)  
    153 153          
    154 154     def __repr__(self):  
  • trunk/nose/plugins/doctests.py

    r21 r26  
    30 30      
    31 31     def add_options(self, parser, env=os.environ):  
    32           super(Doctest, self).add_options(parser, env)  
      32         Plugin.add_options(self, parser, env)  
    32 32         parser.add_option('--doctest-tests', action='store_true',  
    33 33                           dest='doctest_tests',  
     
    47 47  
    48 48     def configure(self, options, config):  
    49           super(Doctest, self).configure(options, config)  
      49         Plugin.configure(self, options, config)  
    49 49         self.doctest_tests = options.doctest_tests  
    50 50         try:  
  • trunk/nose/plugins/base.py

    r23 r26  
    81 81  
    82 82          
    83   class PluginInterface(object):  
      83 class IPluginInterface(object):  
    83 83     """  
    84 84     Nose plugin API  
     
    150 150     """  
    151 151     def __new__(cls, *arg, **kw):  
    152           raise TypeError("PluginInterface class is for documentation only")  
      152         raise TypeError("IPluginInterface class is for documentation only")  
    152 152  
    153 153     def addDeprecated(self, test):  
  • trunk/nose/plugins/cover.py

    r23 r26  
    33 33      
    34 34     def add_options(self, parser, env=os.environ):  
    35           super(Coverage, self).add_options(parser, env)  
    36    
      35         Plugin.add_options(self, parser, env)  
    37 36         parser.add_option("--cover-package", action="append",  
    38 37                           default=env.get('NOSE_COVER_PACKAGE'),  
     
    52 51  
    53 52     def configure(self, options, config):  
    54           super(Coverage, self).configure(options, config)  
      53         Plugin.configure(self, options, config)  
    54 53         if self.enabled:  
    55 54             try:  
  • trunk/nose/plugins/profile.py

    r23 r26  
    21 21     """  
    22 22     def add_options(self, parser, env=os.environ):  
    23           super(Profile, self).add_options(parser, env)                 
      23         Plugin.add_options(self, parser, env)                 
    23 23         parser.add_option('--profile-sort',action='store',dest='profile_sort',  
    24 24                           default=env.get('NOSE_PROFILE_SORT','cumulative'),  
     
    40 40  
    41 41     def configure(self, options, conf):  
    42           super(Profile, self).configure(options, conf)  
      42         Plugin.configure(self, options, conf)  
    42 42         self.options = options  
    43 43         self.conf = conf  
  • trunk/nose/plugins/attrib.py

    r24 r26  
    29 29 import os  
    30 30 import re  
      31 import sys  
    31 32 import textwrap  
    32 33  
    33 34 from nose.plugins.base import Plugin  
    34 35  
      36 pyvrs = sys.version_info  
      37 compat_24 = pyvrs[0] >= 2 and pyvrs[1] >= 4  
      38  
    35 39 class ContextHelper:  
    36 40     """Returns default values for dictionary lookups."""  
     
    46 50  
    47 51     def __init__(self):  
    48           super(AttributeSelector, self).__init__()  
      52         Plugin.__init__(self)  
    48 52         self.attribs = []  
    49 53      
     
    52 56         """Add command-line options for this plugin."""  
    53 57  
    54           # FIXME disable in < 2.4  
    55 58         parser.add_option("-a", "--attr",  
    56 59                           dest="attr", action="append",  
     
    58 61                           help="Run only tests that have attributes "  
    59 62                           "specified by ATTR [NOSE_ATTR]")  
    60           parser.add_option("-A", "--eval-attr",  
    61                             dest="eval_attr", metavar="EXPR", action="append",  
    62                             default=env.get('NOSE_EVAL_ATTR'),  
    63                             help="Run only tests for whose attributes "  
    64                             "the Python expression EXPR evaluates "  
    65                             "to True [NOSE_EVAL_ATTR]")  
      63         # disable in < 2.4: eval can't take needed args  
      64         if compat_24:  
      65             parser.add_option("-A", "--eval-attr",  
      66                               dest="eval_attr", metavar="EXPR", action="append",  
      67                               default=env.get('NOSE_EVAL_ATTR'),  
      68                               help="Run only tests for whose attributes "  
      69                               "the Python expression EXPR evaluates "  
      70                               "to True [NOSE_EVAL_ATTR]")  
    66 71  
    67 72     def configure(self, options, config):  
     
    73 78          
    74 79         # handle python eval-expression parameter  
    75           if options.eval_attr:  
      80         if compat_24 and options.eval_attr:  
    75 80             eval_attr = self.tolist(options.eval_attr)  
    76 81             for attr in eval_attr:  
  • trunk/nose/case.py

    r21 r26  
    35 35     def __init__(self, testFunc, setUp=None, tearDown=None, description=None,  
    36 36                  fromDirectory=None):  
    37           super(FunctionTestCase, self).__init__()  
    38 37         self.testFunc = testFunc  
    39 38         self.setUpFunc = setUp  
     
    41 40         self.description = description  
    42 41         self.fromDirectory = fromDirectory  
    43    
      42         unittest.TestCase.__init__(self)  
      43          
    44 44     def id(self):  
    45 45         return str(self)  
     
    96 96         self.arg = arg  
    97 97         log.debug('Test case: %s%s', self.testCase, self.arg)         
    98           super(MethodTestCase, self).__init__()  
      98         unittest.TestCase.__init__(self)  
    98 98          
    99 99     def __str__(self):  
  • trunk/nose/result.py

    r24 r26  
    141 141                  
    142 142     def addDeprecated(self, test):  
    143           super(TextTestResult, self).addDeprecated(test)  
      143         Result.addDeprecated(self, test)  
    143 143         self.deprecated.append((test, '', ''))  
    144 144         self.writeRes('DEPRECATED','D')  
    145 145          
    146 146     def addError(self, test, err):  
    147           super(TextTestResult, self).addError(test, err)  
      147         Result.addError(self, test, err)  
    147 147         if not self.isDeprecated(err) and not self.isSkip(err):  
    148 148             self.errors.append((test,  
     
    154 154              
    155 155     def addFailure(self, test, err):  
    156           super(TextTestResult, self).addFailure(test, err)  
      156         Result.addFailure(self, test, err)  
    156 156         self.failures.append((test,  
    157 157                               self._exc_info_to_string(err, test) + self.tbinfo,  
     
    161 161          
    162 162     def addSkip(self, test):  
    163           super(TextTestResult, self).addSkip(test)  
      163         Result.addSkip(self, test)  
    163 163         self.skip.append((test, '', ''))  
    164 164         self.writeRes('SKIP','S')  
    165 165  
    166 166     def addSuccess(self, test):  
    167           super(TextTestResult, self).addSuccess(test)  
      167         Result.addSuccess(self, test)  
    167 167         self.writeRes('ok', '.')  
    168 168          
    169 169     def printErrors(self):  
    170 170         log.debug('printErrors called')  
    171           super(TextTestResult, self).printErrors()  
      171         _TextTestResult.printErrors(self)  
    171 171         self.printErrorList('DEPRECATED', self.deprecated)  
    172 172         self.printErrorList('SKIPPED', self.skip)  
  • trunk/nose/selector.py

    r23 r26  
    28 28         """  
    29 29         if not self.tests:  
    30               log.debug("No tests to check")  
    31 30             return True  
    32 31          
  • trunk/nose/proxy.py

    r21 r26  
    12 12      
    13 13     def addError(self, test, err):  
    14           super(ResultProxy, self).addError(test, err)  
      14         Result.addError(self, test, err)  
    14 14          
    15 15         # compose a new error object that includes captured output  
     
    23 23          
    24 24     def addFailure(self, test, err):  
    25           super(ResultProxy, self).addFailure(test, err)  
      25         Result.addFailure(self, test, err)  
    25 25          
    26 26         # compose a new error object that includes captured output  
     
    37 37          
    38 38     def addSuccess(self, test):  
    39           super(ResultProxy, self).addSuccess(test)  
      39         Result.addSuccess(self, test)  
    39 39         self.result.addSuccess(test)  
    40 40      
    41 41     def startTest(self, test):  
    42           super(ResultProxy, self).startTest(test)  
      42         Result.startTest(self, test)  
    42 42         self.result.startTest(test)  
    43 43  
    44 44     def stopTest(self, test):  
    45           super(ResultProxy, self).stopTest(test)  
      45         Result.stopTest(self, test)  
    45 45         self.result.stopTest(test)  
    46 46  
     
    56 56     shouldStop = property(_get_shouldStop, _set_shouldStop)  
    57 57  
      58      
    58 59 class ResultProxySuite(unittest.TestSuite):  
    59 60     def __iter__(self):