Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_colour_validation_always(config):
config.write("color = 'always'\n", 'a')
with patch(
'todoman.configuration.find_config',
return_value=(str(config)),
):
cfg = load_config()
assert cfg['main']['color'] == 'always'
def test_colour_validation_auto(config):
with patch(
'todoman.configuration.find_config',
return_value=(str(config)),
):
cfg = load_config()
assert cfg['main']['color'] == 'auto'
def test_colour_validation_invalid(config):
config.write("color = 'on_weekends_only'\n", 'a')
with patch(
'todoman.configuration.find_config',
return_value=(str(config)),
), pytest.raises(ConfigurationException):
load_config()
def init_config(self):
try:
self.config = load_config()
except ConfigurationException as e:
raise click.ClickException(e.args[0])