Browse Source

Fix subnet config test for windows

Signed-off-by: Drew Romanyk <[email protected]>
Drew Romanyk 8 năm trước cách đây
mục cha
commit
68c636d728
2 tập tin đã thay đổi với 11 bổ sung6 xóa
  1. 6 4
      compose/config/validation.py
  2. 5 2
      tests/unit/config/config_test.py

+ 6 - 4
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
 

+ 5 - 2
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: