def test_noneValueResetToDefault(self): set('autorun', False) value = get("autorun") assert type(value) is bool and not value set('autorun', None) value = get("autorun") assert type(value) is bool and value
def test_noneValueSetToNone(self): set('proxy_port', 42) value = get("proxy_port") assert type(value) is int and value == 42 set('proxy_port', None) value = get("proxy_port") assert value is None
def test_getAStringValue(self): set("proxy_type", 42) value = get("proxy_type") assert (type(value) is str or type(value) is unicode) and value == "42" set("proxy_type", None) value = get("proxy_type") assert (type(value) is str or type(value) is unicode) and value == "HTTP"
def test_setWithoutExistingFile(self): config_path = _get_config_file_path() if exists(config_path): os.remove(config_path) set("lang", "plop") value = get("lang") assert (type(value) is str or type(value) is unicode) and value == "plop"
def test_getADictValue(self): set("log_levels", "aa=bb;cc=dd") value = get("log_levels") assert type(value) is dict assert "aa" in value assert value["aa"] == "bb" assert "cc" in value assert value["cc"] == "dd"
def test_getAkeyNotPresentInFile(self): config_path = _get_config_file_path() # delete the file if exists(config_path): os.remove(config_path) # create the file set("proxy_port", 42) value = get("proxy_type") assert (type(value) is str or type(value) is unicode) and value == "HTTP"
def test_loadWithoutExistingFile(self): config_path = _get_config_file_path() if exists(config_path): os.remove(config_path) # create a config file set('lang', 'plop') assert catcher.lastLogRecord is None load() assert catcher.lastLogRecord is None assert get('lang') == 'plop'
def test_setWithExistingFile(self): config_path = _get_config_file_path() if exists(config_path): os.remove(config_path) # create the file set("lang", "plop") # overwrite the file set("autorun", True) value = get("lang") assert (type(value) is str or type(value) is unicode) and value == "plop" value = get("autorun") assert type(value) is bool and value
def test_getAnIntValue(self): set("proxy_port", 42) value = get("proxy_port") assert type(value) is int and value == 42 set("proxy_port", "42") value = get("proxy_port") assert type(value) is int and value == 42 set("proxy_port", None) value = get("proxy_port") assert value is None
def test_getABoolValue(self): set("autorun", False) value = get("autorun") assert type(value) is bool and not value set("autorun", "False") value = get("autorun") assert type(value) is bool and not value set("autorun", None) value = get("autorun") assert type(value) is bool and value
def test_setANotString(self): set("lang", 42) value = get("lang") assert (type(value) is str or type(value) is unicode) and value == "42"
def test_setAString(self): set("lang", "plop") value = get("lang") assert (type(value) is str or type(value) is unicode) and value == "plop"
def test_getAnIntWithInvalidValue(self): set("proxy_port", 42) _config_parser.set('config', "proxy_port", "plop") value = get("proxy_port") assert value is None
def test_getABoolWithInvalidValue(self): set("autorun", False) _config_parser.set('config', "autorun", "plop") value = get("autorun") assert type(value) is bool and value
def test_keyDoesNotExist(self): with pytest.raises(KeyError): set("plop", 42)