Changeset 5174

Show
Ignore:
Timestamp:
08/20/08 11:36:15 (5 months ago)
Author:
carndt
Message:

Make config package discovery in 'testutil.py' more robust by only considering packages whose names start with a valid identifier char.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/turbogears/testutil.py

    r4741 r5174  
    22import types 
    33import logging 
     4import string 
    45import unittest 
    56import Cookie 
     
    4445# Load test configuration 
    4546if os.path.exists('test.cfg'): 
    46     for w in os.walk('.'): 
    47         if w[0].endswith(os.sep + 'config') and not os.sep + '.' in w[0]: 
    48             modulename = "%s.app" % w[0][2:].replace(os.sep, ".") 
    49             break 
     47    # Look for a 'config' package 
     48    for dirpath, dirs, dummy2 in os.walk('.'): 
     49        basename = os.path.basename(dirpath) 
     50        dirname = os.path.dirname(dirpath) 
     51        init_py = os.path.join(dirpath, '__init__.py') 
     52        if basename == 'config' and os.path.exists(init_py) and \ 
     53                dirname[0] in string.ascii_letters + '_': 
     54            modulename = "%s.app" % dirpath[2:].replace(os.sep, ".") 
    5055    else: 
    5156        modulename = None