cubicweb/test/unittest_cwconfig.py
branch3.26
changeset 12274 d2e9999861a5
parent 12273 9d08f89a3d85
child 12498 1ec5b23b92e7
equal deleted inserted replaced
12273:9d08f89a3d85 12274:d2e9999861a5
    34 
    34 
    35 from cubicweb.devtools import ApptestConfiguration
    35 from cubicweb.devtools import ApptestConfiguration
    36 from cubicweb.devtools.testlib import BaseTestCase, TemporaryDirectory
    36 from cubicweb.devtools.testlib import BaseTestCase, TemporaryDirectory
    37 from cubicweb.cwconfig import (
    37 from cubicweb.cwconfig import (
    38     CubicWebConfiguration, _expand_modname)
    38     CubicWebConfiguration, _expand_modname)
    39 
       
    40 
       
    41 def unabsolutize(path):
       
    42     parts = path.split(os.sep)
       
    43     for i, part in reversed(tuple(enumerate(parts))):
       
    44         if part.startswith('cubicweb_'):
       
    45             return os.sep.join([part[len('cubicweb_'):]] + parts[i + 1:])
       
    46         if part.startswith('cubicweb') or part == 'legacy_cubes':
       
    47             return os.sep.join(parts[i + 1:])
       
    48     raise Exception('duh? %s' % path)
       
    49 
    39 
    50 
    40 
    51 def templibdir(func):
    41 def templibdir(func):
    52     """create a temporary directory and insert it in sys.path"""
    42     """create a temporary directory and insert it in sys.path"""
    53     @functools.wraps(func)
    43     @functools.wraps(func)