Changeset 122
- Timestamp:
- Thu Nov 16 12:11:08 2006
- Files:
-
- branches/new_loader/nose/util.py (modified) (diff)
- branches/new_loader/nose/selector.py (modified) (diff)
- branches/new_loader/work.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
branches/new_loader/nose/util.py
r117 r122 209 209 return func() 210 210 211 212 def src(filename): 213 """Find the python source file for a .pyc or .pyo file. Returns the 214 filename provided if it is not a python source file. 215 """ 216 if filename is None: 217 return filename 218 base, ext = os.path.splitext(filename) 219 if ext in ('.pyc', '.pyo', '.py'): 220 return '.'.join((base, 'py')) 221 return filename 211 222 212 223 def tolist(val): -
branches/new_loader/nose/selector.py
r120 r122 6 6 from nose.config import Config 7 7 from nose.plugins import call_plugins 8 from nose.util import absfile, file_like, split_test_name, test_address 8 from nose.util import absfile, file_like, split_test_name, src, test_address 8 8 9 9 log = logging.getLogger(__name__) … … 413 413 self.filename, self.module, self.call = split_test_name(name) 414 414 if self.filename is not None: 415 if (self.filename.endswith('.pyc') 416 or self.filename.endswith('.pyo')): 417 self.filename = self.filename[:-3] + 'py' 415 self.filename = src(self.filename) 418 416 if not os.path.isabs(self.filename): 419 417 self.filename = os.path.abspath(os.path.join(working_dir, … … 468 466 is None. 469 467 """ 468 log.debug("Match file %s vs module %s", filename, self.module) 470 469 mn = self.module 471 470 if mn is None: … … 475 474 return True 476 475 476 filename = src(filename) 477 base, ext = os.path.splitext(filename) 478 if ext and ext != '.py': 479 # not a python source file: can't be a module 480 log.debug("%s is not a python source file (%s)", filename, ext) 481 return False 482 477 483 # Turn the module name into a path and compare against 478 484 # the filename, with the file extension and working_dir removed 485 sep = os.path.sep 479 486 mpath = os.path.sep.join(mn.split('.')) 480 base = os.path.splitext(filename)[0][len(self.working_dir):] 481 mod_match_re = re.compile(r'(^|/)%s(/|$)' % mpath) 482 result = mod_match_re.search(base) 483 return result 487 base = base[len(self.working_dir):] 488 log.debug("Match file %s (from module %s) vs %s", mpath, mn, base) 489 mod_match_re = re.compile(r'(^|%s)%s(%s|$)' % (sep, mpath, sep)) 490 if mod_match_re.search(base): 491 # the file is likely to be a subpackage of my module 492 log.debug('%s is a subpackage of %s', filename, mn) 493 return True 494 # Now see if my module might be a subpackage of the file 495 rev_match_re = re.compile(r'%s(%s|$)' % (base, sep)) 496 if rev_match_re.match(sep + mpath): 497 log.debug('%s is a subpackage of %s', mn, filename) 498 return True 499 return False 500 484 501 485 502 def matches_function(self, function): … … 519 536 extension replaced by .py. 520 537 """ 521 mod_file = module.__file__ 522 if mod_file.endswith('.pyc') or mod_file.endswith('.pyo'): 523 mod_file = mod_file[:-3] + 'py' 538 mod_file = src(module.__file__) 539 log.debug('Trying to matching module file %s as file', mod_file) 524 540 return self.matches_file(mod_file) 525 541 -
branches/new_loader/work.py
r120 r122 191 191 #'test-dir/' => 'support/test-dir/test.py' 192 192 #'test' => 'support/test.py' 193 # 'foo.bar' => 'support/foo/bar' * 194 193 # 'foo.bar' => 'support/foo/bar' * not working maybe because of __init__.py 194 # in the filename / wantDirectory is failing 195 # to include foo 195 196
