From fa61a91cb5056767ba4b72faf99c295a4372e25b Mon Sep 17 00:00:00 2001 From: Drew Romanyk Date: Thu, 9 Nov 2017 22:57:47 -0600 Subject: [PATCH] Fix subnet config test for windows Signed-off-by: Drew Romanyk --- compose/config/validation.py | 10 ++++++---- tests/unit/config/config_test.py | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/compose/config/validation.py b/compose/config/validation.py index a8061a5a4..c2256804b 100644 --- a/compose/config/validation.py +++ b/compose/config/validation.py @@ -72,22 +72,24 @@ def format_expose(instance): def format_subnet_ip_address(instance): if isinstance(instance, six.string_types): if '/' not in instance: - raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'") + raise ValidationError("'{0}' 75 should be of the format 'IP_ADDRESS/CIDR'".format(instance)) ip_address, cidr = instance.split('/') if re.match(VALID_IPV4_FORMAT, ip_address): if not (re.match(VALID_IPV4_CIDR_FORMAT, cidr) and all(0 <= int(component) <= 255 for component in ip_address.split("."))): - raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'") + raise ValidationError( + "'{0}' 83 should be of the format 'IP_ADDRESS/CIDR'".format(instance)) elif re.match(VALID_IPV6_CIDR_FORMAT, cidr) and hasattr(socket, "inet_pton"): try: if not (socket.inet_pton(socket.AF_INET6, ip_address)): - raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'") + raise ValidationError( + "'{0}' 88 should be of the format 'IP_ADDRESS/CIDR'".format(instance)) except socket.error as e: raise ValidationError(six.text_type(e)) else: - raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'") + raise ValidationError("'{0}' 92 should be of the format 'IP_ADDRESS/CIDR'".format(instance)) return True diff --git a/tests/unit/config/config_test.py b/tests/unit/config/config_test.py index 819d8f5be..51323cd32 100644 --- a/tests/unit/config/config_test.py +++ b/tests/unit/config/config_test.py @@ -2896,8 +2896,11 @@ class SubnetTest(unittest.TestCase): for invalid_subnet in self.ILLEGAL_SUBNET_MAPPINGS: with pytest.raises(ConfigurationError) as exc: self.check_config(invalid_subnet) - - assert "illegal IP address string" in exc.value.msg + if IS_WINDOWS_PLATFORM: + assert "An invalid argument was supplied" in exc.value.msg or \ + "illegal IP address string" in exc.value.msg + else: + assert "illegal IP address string" in exc.value.msg def test_config_valid_subnet_format_validation(self): for valid_subnet in self.VALID_SUBNET_MAPPINGS: