Changeset 5708

Show
Ignore:
Timestamp:
11/18/08 10:38:03 (2 months ago)
Author:
carndt
Message:

Temporary fix for dodgy configuration loading in turbogears.testutil (see #2043)

Files:

Legend:

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

    r5696 r5708  
    4242    for dirpath, dirs, dummy2 in os.walk('.'): 
    4343        basename = os.path.basename(dirpath) 
    44         dirname = os.path.normpath(os.path.dirname(dirpath)) 
     44        dirname = os.path.basename(os.path.dirname(dirpath)) 
    4545        init_py = os.path.join(dirpath, '__init__.py') 
    46         if basename == 'config' and os.path.exists(init_py) and
    47                 dirname[0] in string.ascii_letters + '_'
     46        if basename == 'config' and dirname[0] in string.ascii_letters + '_'
     47                and os.path.exists(init_py)
    4848            modulename = "%s.app" % dirpath[2:].replace(os.sep, ".") 
    4949            break 
    5050    else: 
    5151        modulename = None 
    52     update_config(configfile="test.cfg", modulename=modulename) 
     52    # XXX This is a temporary workaround, the code above to find the config 
     53    # package should really be improved and moved elsewhere. 
     54    # See http://trac.turbogears.org/ticket/2043 
     55    try: 
     56        update_config(configfile="test.cfg", modulename=modulename) 
     57    except ImportError, exc: 
     58        import warnings 
     59        warnings.warn("Could not import configuration from module: %s" % exc, 
     60            RuntimeWarning) 
     61        update_config(configfile="test.cfg", modulename=None) 
    5362else: 
    5463    database.set_db_uri("sqlite:///:memory:")