Esempio n. 1
0
def test_config_file():
    from astropy.config.configuration import get_config, reload_config

    apycfg = get_config('astropy')
    assert apycfg.filename.endswith('astropy.cfg')

    cfgsec = get_config('astropy.config')
    assert cfgsec.depth == 1
    assert cfgsec.name == 'config'
    assert cfgsec.parent.filename.endswith('astropy.cfg')

    reload_config('astropy')
Esempio n. 2
0
def test_config_file():
    from astropy.config.configuration import get_config, reload_config

    apycfg = get_config('astropy')
    assert apycfg.filename.endswith('astropy.cfg')

    cfgsec = get_config('astropy.config')
    assert cfgsec.depth == 1
    assert cfgsec.name == 'config'
    assert cfgsec.parent.filename.endswith('astropy.cfg')

    reload_config('astropy')
Esempio n. 3
0
def test_config_file():
    from astropy.config.configuration import get_config, reload_config

    apycfg = get_config('astropy')
    assert apycfg.filename.endswith('astropy.cfg')

    cfgsec = get_config('astropy.config')
    assert cfgsec.depth == 1
    assert cfgsec.name == 'config'
    assert cfgsec.parent.filename.endswith('astropy.cfg')

    # try with a different package name, still inside astropy config dir:
    testcfg = get_config('testpkg', rootname='astropy')
    parts = os.path.normpath(testcfg.filename).split(os.sep)
    assert '.astropy' in parts or 'astropy' in parts
    assert parts[-1] == 'testpkg.cfg'
    configuration._cfgobjs['testpkg'] = None  # HACK

    # try with a different package name, no specified root name (should
    #   default to astropy):
    testcfg = get_config('testpkg')
    parts = os.path.normpath(testcfg.filename).split(os.sep)
    assert '.astropy' in parts or 'astropy' in parts
    assert parts[-1] == 'testpkg.cfg'
    configuration._cfgobjs['testpkg'] = None  # HACK

    # try with a different package name, specified root name:
    testcfg = get_config('testpkg', rootname='testpkg')
    parts = os.path.normpath(testcfg.filename).split(os.sep)
    assert '.testpkg' in parts or 'testpkg' in parts
    assert parts[-1] == 'testpkg.cfg'
    configuration._cfgobjs['testpkg'] = None  # HACK

    # try with a subpackage with specified root name:
    testcfg_sec = get_config('testpkg.somemodule', rootname='testpkg')
    parts = os.path.normpath(testcfg_sec.parent.filename).split(os.sep)
    assert '.testpkg' in parts or 'testpkg' in parts
    assert parts[-1] == 'testpkg.cfg'
    configuration._cfgobjs['testpkg'] = None  # HACK

    reload_config('astropy')