Пример #1
0
    def __parse_configuration_section(input_stream):
        config = {}

        for line in input_stream:
            if line == u'\x0A':
                break

            m = re.search('^([^:]+): (.*)$', line, re.MULTILINE)
            config[m.group(1)] = m.group(2)

        return TimeWarriorConfig(config)
Пример #2
0
def test_get_boolean_should_return_false_on_falseish_values(falseish_value):
    config = TimeWarriorConfig({'KEY': falseish_value})

    assert config.get_boolean('KEY', True) is False
Пример #3
0
def test_get_value_should_return_value_if_key_available():
    config = TimeWarriorConfig({'FOO': 'foo'})

    assert config.get_value('FOO', 'bar') == 'foo'
Пример #4
0
def test_get_boolean_should_return_true_on_trueish_values(trueish_value):
    config = TimeWarriorConfig({'KEY': trueish_value})

    assert config.get_boolean('KEY', False) is True
Пример #5
0
def test_get_int_should_return_default_if_key_not_available():
    config = TimeWarriorConfig({'BAR': '1'})

    assert config.get_int('FOO', 2) == 2
Пример #6
0
def test_get_int_should_return_raise_exception_for_invalid_strings():
    with pytest.raises(ValueError):
        config = TimeWarriorConfig({'KEY': 'bla'})

        config.get_int('KEY', 2)
Пример #7
0
def test_get_int_should_return_value_for_valid_strings():
    config = TimeWarriorConfig({'KEY': '1'})

    assert config.get_int('KEY', 2) == 1
Пример #8
0
def test_get_boolean_should_return_default_if_key_not_available():
    config = TimeWarriorConfig({})

    assert config.get_boolean('FOO', True) is True