Esempio n. 1
0
def test_that_set_config_creates_directories_if_required():
    with _directory_sandbox() as d:
        os.environ['XDG_CONFIG_HOME'] = d + '/.config'
        if 'STBT_CONFIG_FILE' in os.environ:
            del os.environ['STBT_CONFIG_FILE']
        _set_config('global', 'test', 'hello2')
        assert os.path.isfile(d + '/.config/stbt/stbt.conf')
        _config_init(force=True)
        assert get_config('global', 'test') == 'hello2'
def test_that_set_config_creates_directories_if_required():
    with _directory_sandbox() as d:
        os.environ['XDG_CONFIG_HOME'] = d + '/.config'
        if 'STBT_CONFIG_FILE' in os.environ:
            del os.environ['STBT_CONFIG_FILE']
        _set_config('global', 'test', 'hello2')
        assert os.path.isfile(d + '/.config/stbt/stbt.conf')
        _config_init(force=True)
        assert get_config('global', 'test') == 'hello2'
Esempio n. 3
0
def test_that_set_config_preserves_file_comments_and_formatting():
    # pylint:disable=W0511,W0101
    # FIXME: Preserve comments and formatting.  This is fairly tricky as
    # comments and whitespace are not currently stored in Python's internal
    # ConfigParser representation and multiline values makes just using regex
    # tricky.
    from nose import SkipTest
    raise SkipTest("set_config doesn't currently preserve formatting")
    with set_config_test():
        _set_config('global', 'test', 'goodbye')
        assert open('test.cfg',
                    'r').read() == test_config.replace('hello', 'goodbye')
Esempio n. 4
0
def test_that_set_config_preserves_file_comments_and_formatting():
    # pylint:disable=W0511,W0101
    # FIXME: Preserve comments and formatting.  This is fairly tricky as
    # comments and whitespace are not currently stored in Python's internal
    # ConfigParser representation and multiline values makes just using regex
    # tricky.
    from nose import SkipTest
    raise SkipTest("set_config doesn't currently preserve formatting")
    with set_config_test():
        _set_config('global', 'test', 'goodbye')
        assert open('test.cfg', 'r').read() == test_config.replace(
            'hello', 'goodbye')
Esempio n. 5
0
def test_that_set_config_creates_new_sections_if_required():
    with set_config_test():
        _set_config('non_existent_section', 'test', 'goodbye')
        assert get_config('non_existent_section', 'test', 'goodbye')
        _config_init(force=True)
        assert get_config('non_existent_section', 'test', 'goodbye')
Esempio n. 6
0
def test_that_set_config_modifies_config_value():
    with set_config_test():
        _set_config('global', 'test', 'goodbye')
        assert get_config('global', 'test', 'goodbye')
        _config_init(force=True)
        assert get_config('global', 'test', 'goodbye')
Esempio n. 7
0
def test_that_set_config_modifies_config_value():
    with set_config_test():
        _set_config('global', 'test', 'goodbye')
        assert get_config('global', 'test', 'goodbye')
        _config_init(force=True)
        assert get_config('global', 'test', 'goodbye')
def test_that_set_config_creates_new_sections_if_required():
    with set_config_test():
        _set_config('non_existent_section', 'test', 'goodbye')
        assert get_config('non_existent_section', 'test', 'goodbye')
        _config_init(force=True)
        assert get_config('non_existent_section', 'test', 'goodbye')