mirror of https://github.com/docker/compose.git
Fix parse_key_from_error_msg to not error out on non-string keys
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
4682e766a3
commit
dce70a5566
|
@ -330,7 +330,10 @@ def handle_generic_error(error, path):
|
|||
|
||||
|
||||
def parse_key_from_error_msg(error):
|
||||
try:
|
||||
return error.message.split("'")[1]
|
||||
except IndexError:
|
||||
return error.message.split('(')[1].split(' ')[0].strip("'")
|
||||
|
||||
|
||||
def path_string(path):
|
||||
|
|
|
@ -613,6 +613,19 @@ class ConfigTest(unittest.TestCase):
|
|||
excinfo.exconly()
|
||||
)
|
||||
|
||||
def test_config_integer_service_property_raise_validation_error(self):
|
||||
with pytest.raises(ConfigurationError) as excinfo:
|
||||
config.load(
|
||||
build_config_details({
|
||||
'version': '2.1',
|
||||
'services': {'foobar': {'image': 'busybox', 1234: 'hah'}}
|
||||
}, 'working_dir', 'filename.yml')
|
||||
)
|
||||
|
||||
assert (
|
||||
"Unsupported config option for services.foobar: '1234'" in excinfo.exconly()
|
||||
)
|
||||
|
||||
def test_config_invalid_service_name_raise_validation_error(self):
|
||||
with pytest.raises(ConfigurationError) as excinfo:
|
||||
config.load(
|
||||
|
|
Loading…
Reference in New Issue