Changeset 130

Show
Ignore:
Timestamp:
Wed Nov 22 22:33:49 2006
Author:
jpellerin
Message:

Fixed insane implementations of xxxInTests; bumped branch version to 0.10.0a1

Files:

Legend:

Unmodified
Added
Removed
Modified
  • branches/new_loader/unit_tests/test_selector.py

    r123 r130  
    281 281  
    282 282         tests = test_addr([ 'what' ])  
    283           assert s.moduleInTests(tests)(w)  
    284           assert s.moduleInTests(tests, True)(w)  
    285           assert s.moduleInTests(tests)(w_e)  
    286           assert s.moduleInTests(tests, True)(w_e)  
    287           assert s.moduleInTests(tests)(w_n)  
    288           assert s.moduleInTests(tests, True)(w_n)  
    289           assert not s.moduleInTests(tests)(we)  
    290           assert not s.moduleInTests(tests, True)(we)  
    291           assert not s.moduleInTests(tests)(f_e)  
    292           assert not s.moduleInTests(tests, True)(f_e)  
      283         assert s.moduleInTests(w, tests)  
      284         assert s.moduleInTests(w, tests, True)  
      285         assert s.moduleInTests(w_e, tests)  
      286         assert s.moduleInTests(w_e, tests, True)  
      287         assert s.moduleInTests(w_n, tests)  
      288         assert s.moduleInTests(w_n, tests, True)  
      289         assert not s.moduleInTests(we, tests)  
      290         assert not s.moduleInTests(we, tests, True)  
      291         assert not s.moduleInTests(f_e, tests)  
      292         assert not s.moduleInTests(f_e, tests, True)  
    293 293  
    294 294         tests = test_addr([ 'what.ever' ])  
    295           assert not s.moduleInTests(tests)(w)  
    296           assert s.moduleInTests(tests, True)(w)  
    297           assert s.moduleInTests(tests)(w_e)  
    298           assert s.moduleInTests(tests, True)(w_e)  
    299           assert not s.moduleInTests(tests)(w_n)  
    300           assert not s.moduleInTests(tests, True)(w_n)  
    301           assert not s.moduleInTests(tests)(we)  
    302           assert not s.moduleInTests(tests, True)(we)  
    303           assert not s.moduleInTests(tests)(f_e)  
    304           assert not s.moduleInTests(tests, True)(f_e)  
      295         assert not s.moduleInTests(w, tests)  
      296         assert s.moduleInTests(w, tests, True)  
      297         assert s.moduleInTests(w_e, tests)  
      298         assert s.moduleInTests(w_e, tests, True)  
      299         assert not s.moduleInTests(w_n, tests)  
      300         assert not s.moduleInTests(w_n, tests, True)  
      301         assert not s.moduleInTests(we, tests)  
      302         assert not s.moduleInTests(we, tests, True)  
      303         assert not s.moduleInTests(f_e, tests)  
      304         assert not s.moduleInTests(f_e, tests, True)  
    305 305  
    306 306         tests = test_addr([ 'what.ever', 'what.not' ])  
    307           assert not s.moduleInTests(tests)(w)  
    308           assert s.moduleInTests(tests, True)(w)  
    309           assert s.moduleInTests(tests)(w_e)  
    310           assert s.moduleInTests(tests, True)(w_e)  
    311           assert s.moduleInTests(tests)(w_n)  
    312           assert s.moduleInTests(tests, True)(w_n)  
    313           assert not s.moduleInTests(tests)(we)  
    314           assert not s.moduleInTests(tests, True)(we)  
    315           assert not s.moduleInTests(tests)(f_e)  
    316           assert not s.moduleInTests(tests, True)(f_e)  
      307         assert not s.moduleInTests(w, tests)  
      308         assert s.moduleInTests(w, tests, True)  
      309         assert s.moduleInTests(w_e, tests)  
      310         assert s.moduleInTests(w_e, tests, True)  
      311         assert s.moduleInTests(w_n, tests)  
      312         assert s.moduleInTests(w_n, tests, True)  
      313         assert not s.moduleInTests(we, tests)  
      314         assert not s.moduleInTests(we, tests, True)  
      315         assert not s.moduleInTests(f_e, tests)  
      316         assert not s.moduleInTests(f_e, tests, True)  
    317 317  
    318 318     def test_module_in_tests_file(self):  
     
    328 328          
    329 329         tests = test_addr([ 'test.py' ], base)  
    330           assert not s.moduleInTests(tests)(f)  
    331           assert s.moduleInTests(tests)(t)  
    332           assert not s.moduleInTests(tests)(f_t_f)  
    333           assert not s.moduleInTests(tests)(d_t_t)  
      330         assert not s.moduleInTests(f, tests)  
      331         assert s.moduleInTests(t, tests)  
      332         assert not s.moduleInTests(f_t_f, tests)  
      333         assert not s.moduleInTests(d_t_t, tests)  
    334 334          
    335 335         tests = test_addr([ 'foo/' ], base)  
    336           assert s.moduleInTests(tests)(f)  
    337           assert s.moduleInTests(tests)(f_t_f)  
    338           assert not s.moduleInTests(tests)(t)  
    339           assert not s.moduleInTests(tests)(d_t_t)  
      336         assert s.moduleInTests(f, tests)  
      337         assert s.moduleInTests(f_t_f, tests)  
      338         assert not s.moduleInTests(t, tests)  
      339         assert not s.moduleInTests(d_t_t, tests)  
    340 340  
    341 341         tests = test_addr([ 'foo/test_foo.py' ], base)  
    342           assert not s.moduleInTests(tests)(f)  
    343           assert s.moduleInTests(tests)(f_t_f)  
    344           assert not s.moduleInTests(tests)(t)  
    345           assert not s.moduleInTests(tests)(d_t_t)  
      342         assert not s.moduleInTests(f, tests)  
      343         assert s.moduleInTests(f_t_f, tests)  
      344         assert not s.moduleInTests(t, tests)  
      345         assert not s.moduleInTests(d_t_t, tests)  
    346 346          
    347 347         tests = test_addr([ 'test-dir/test.py' ], base)  
    348           assert not s.moduleInTests(tests)(f)  
    349           assert not s.moduleInTests(tests)(t)  
    350           assert not s.moduleInTests(tests)(f_t_f)  
    351           assert s.moduleInTests(tests)(d_t_t)  
      348         assert not s.moduleInTests(f, tests)  
      349         assert not s.moduleInTests(t, tests)  
      350         assert not s.moduleInTests(f_t_f, tests)  
      351         assert s.moduleInTests(d_t_t, tests)  
    352 352  
    353 353  
  • branches/new_loader/nose/__init__.py

    r125 r130  
    298 298  
    299 299 __author__ = 'Jason Pellerin'  
    300   __versioninfo__ = (0, 9, 2)  
      300 __versioninfo__ = (0, 10, '0a1')  
    300 300 __version__ = '.'.join(map(str, __versioninfo__))  
    301 301  
  • branches/new_loader/nose/selector.py

    r123 r130  
    19 19         self.configure(conf)  
    20 20  
    21       def classInTests(self, tests):  
      21     def classInTests(self, cls, tests=None):  
    21 21         if tests is None:  
    22               in_tests = match_all  
    23           else:  
    24               def in_tests(cls):  
    25                   return filter(None,  
    26                                 [ t.matches_class(cls) for t in tests])  
    27           return in_tests  
      22             return True  
      23         return filter(None,  
      24                       [ t.matches_class(cls) for t in tests])  
    28 25  
    29 26     def configure(self, conf):  
     
    35 32         self.match = conf.testMatch  
    36 33  
    37       def fileInTests(self, tests):  
      34     def fileInTests(self, file, tests=None):  
    37 34         if tests is None:  
    38               in_tests = match_all  
      35             return True  
    38 35         else:  
    39               def in_tests(file):  
    40                   return filter(None,  
    41                                 [ t.matches_file(file) for t in tests ])  
    42           return in_tests  
      36             return filter(None,  
      37                           [ t.matches_file(file) for t in tests ])  
    43 38      
    44       def funcInTests(self, tests):  
      39     def funcInTests(self, func, tests=None):  
    44 39         if tests is None:  
    45               in_tests = match_all  
    46           else:  
    47               def in_tests(func):  
    48                   return filter(None,  
    49                                 [ t.matches_function(func) for t in tests ])  
    50           return in_tests  
      40             return True  
      41         return filter(None,  
      42                       [ t.matches_function(func) for t in tests ])  
    51 43          
    52 44     def matches(self, name):  
     
    68 60                  ))  
    69 61  
    70       def methodInTests(self, tests):  
      62     def methodInTests(self, method, tests=None):  
    70 62         """Determine if a method is listed in the requested tests. To  
    71 63         be consideed a match, the method's class must be in the class  
     
    75 67         """  
    76 68         if tests is None:  
    77               in_tests = match_all  
    78           else:  
    79               def in_tests(method):  
    80                   return filter(None,  
    81                                 [ t.matches_method(method) for t in tests ])  
    82           return in_tests  
      69             return True  
      70         return filter(None,  
      71                       [ t.matches_method(method) for t in tests ])  
    83 72  
    84       def moduleInTests(self, tests, either=False):  
      73     def moduleInTests(self, module, tests=None, either=False):  
    84 73         """Return a function that can tell whether a module is in this  
    85 74         batch of tests.  
     
    89 78         """         
    90 79         if tests is None:  
    91               in_tests = match_all  
    92           else:  
    93               def in_tests(module):  
    94                   return filter(None,  
    95                                 [ t.matches_module(module, either)  
    96                                   for t in tests ])  
    97           return in_tests  
      80             return True  
      81         return filter(None,  
      82                       [ t.matches_module(module, either) for t in tests ])  
    98 83      
    99 84     def wantClass(self, cls, tests=None):  
     
    116 101             log.debug("Plugin setting selection of %s to %s", cls, plug_wants)  
    117 102             wanted = plug_wants  
    118           return wanted and self.classInTests(tests)(cls)  
      103         return wanted and self.classInTests(cls, tests)  
    118 103  
    119 104     def wantDirectory(self, dirname, tests=None):  
     
    141 126         if plug_wants is not None:  
    142 127             wanted = plug_wants  
    143           in_tests = self.fileInTests(tests)(dirname)  
      128         in_tests = self.fileInTests(dirname, tests)  
    143 128         log.debug("wantDirectory %s wanted %s, in_tests %s",  
    144 129                   dirname, wanted, in_tests)  
     
    169 154             log.info('%s is executable; skipped', file)  
    170 155             return False  
    171           in_tests = self.fileInTests(tests)(file)  
      156         in_tests = self.fileInTests(file, tests)  
    171 156         if not in_tests:  
    172 157             return False  
     
    197 182             # not a function  
    198 183             return False  
    199           in_tests = self.funcInTests(tests)(function)  
      184         in_tests = self.funcInTests(function, tests)  
    199 184         if not in_tests:  
    200 185             return False     
     
    221 206             # never collect 'private' methods  
    222 207             return False  
    223           in_tests = self.methodInTests(tests)(method)  
      208         in_tests = self.methodInTests(method, tests)  
    223 208         if not in_tests:  
    224 209             return False         
     
    240 225         modules where wantModuleTests() is true.  
    241 226         """  
    242           in_tests = self.moduleInTests(tests, either=True)(module)  
      227         in_tests = self.moduleInTests(module, tests, either=True)  
    242 227         if not in_tests:  
    243 228             return False         
     
    260 245         tests, but instead cause the standard collector to collect tests.  
    261 246         """  
    262           in_tests = self.moduleInTests(tests)(module)  
      247         in_tests = self.moduleInTests(module, tests)  
    262 247         if not in_tests:  
    263 248             return False  
     
    447 432         return self.matches_file(mod_file)  
    448 433  
      434  
    449 435 # Helpers  
    450 436 def match_all(*arg, **kw):  
    451 437     return True  
    452 438  
      439  
    453 440 def subpackage_of(modname, package):  
    454 441     """Is module modname a subpackage of package?"""  
     
    473 460         return False  
    474 461     return True  
      462  
    475 463      
    476 464 def test_addr(names, working_dir=None):