Changeset 82

Show
Ignore:
Timestamp:
Fri Jul 28 16:37:46 2006
Author:
jpellerin
Message:

Removed deprecated method Selector.callableInTests.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/nose/selector.py

    r81 r82  
    40 40         return res  
    41 41  
    42       def callableInTests(self, clb, matches):  
    43           """Does callable clb (a class, method, or function) match anything in  
    44           self.tests?  
    45    
    46           The callable must be from the file or module, if either is defined. If  
    47           it does and the fn part of the test is defined, matches() will be  
    48           called with the callable, and the fn part of the test, and the return  
    49           value of matches() will be returned. Otherwise, if any test container  
    50           without an fn part matches, None is returned. If no container matches,  
    51           false is returned     
    52           """  
    53           def match(filename, modname, funcname, clb=clb, matches=matches):  
    54               containerMatch = False  
    55               if filename is not None:  
    56                   orig = filename  
    57                   # always compare with the *source* file  
    58                   if (filename.endswith('.pyc')                     
    59                       or filename.endswith('.pyo')):  
    60                       filename = filename[:-3] + 'py'  
    61                   if not os.path.isabs(filename):  
    62                       filename = absfile(filename, self.conf.working_dir)  
    63                       if filename is None:  
    64                           log.debug("File %s not found",  orig)  
    65                           return False  
    66                   log.debug("Check file match for callable %s in module %s",  
    67                             clb, clb.__module__)  
    68                   try:  
    69                       mod_file = sys.modules[clb.__module__].__file__  
    70                       # always compare against the *source* file  
    71                       if (mod_file.endswith('.pyc')  
    72                           or mod_file.endswith('.pyo')):  
    73                           mod_file = mod_file[:-3] + 'py'  
    74                       log.debug("module file: %s", mod_file)  
    75                       if not os.path.isabs(mod_file):  
    76                           mod_file = absfile(mod_file, self.conf.working_dir)  
    77                       log.debug("%s == %s?", mod_file, filename)  
    78                       if mod_file == filename:  
    79                           log.debug("File matches")  
    80                           containerMatch = True  
    81                   except AttributeError:  
    82                       # we tried to look at something in __builtin__,  
    83                       # for instance  
    84                       return False  
    85               if modname is not None and not containerMatch:  
    86                   try:  
    87                       log.debug("Check container match: %s v %s",  
    88                                 clb.__module__, modname)  
    89                       if clb.__module__.startswith(modname):  
    90                           containerMatch = True  
    91                   except AttributeError:  
    92                       # some kind of weird attribute; this can't be a test  
    93                       return False  
    94               if ((filename is not None or modname is not None)  
    95                   and not containerMatch):  
    96                   return False  
    97               if funcname is not None:  
    98                   return matches(clb, funcname)  
    99               return None  
    100           return self.anytest(match)  
    101    
    102 42     def classInTests(self, cls):  
    103 43         def match(filename, modname, funcname, cls=cls):