Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def restore_config_data():
yield
Config.data = castero.config._Config().data
def test_config_length():
myconfig = config._Config()
assert isinstance(len(myconfig), int) and len(myconfig) > 0
def test_config_try_set_item():
myconfig = config._Config()
myconfig["fake"] = "value"
assert "fake" not in myconfig
def test_config_get_item():
myconfig = config._Config()
seek_distance_forward = myconfig["seek_distance_forward"]
assert seek_distance_forward is not None
def test_config_iter():
myconfig = config._Config()
for key in myconfig:
assert key in myconfig
def test_config_incomplete_migrate():
copyfile(my_dir + "/datafiles/incomplete_error.conf", config._Config.PATH)
myconfig = config._Config()
assert len(myconfig) > 0
def test_config_del_item():
myconfig = config._Config()
del myconfig["seek_distance_forward"]
assert "seek_distance_forward" not in myconfig
def test_config_default():
myconfig = config._Config()
assert isinstance(myconfig, config._Config)
def test_config_excessive_migrate():
copyfile(my_dir + "/datafiles/excessive_error.conf", config._Config.PATH)
myconfig = config._Config()
assert "this_should_not_be_here" not in myconfig
assert "seek_distance_forward" in myconfig
assert "seek_distance_backward" in myconfig
def test_config_parse_error():
config._Config.DEFAULT_PATH = my_dir + "/datafiles/parse_error.conf"
with pytest.raises(config.ConfigParseError):
config._Config()