mirror of https://github.com/docker/docker-py.git
Raise an error when passing an empty string to split_port
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
c2d114c067
commit
54b3c364cb
|
@ -67,6 +67,8 @@ def split_port(port):
|
|||
|
||||
if len(parts) == 1:
|
||||
internal_port, = parts
|
||||
if not internal_port:
|
||||
_raise_invalid_port(port)
|
||||
return to_port_range(internal_port), None
|
||||
if len(parts) == 2:
|
||||
external_port, internal_port = parts
|
||||
|
|
|
@ -23,8 +23,6 @@ class InformationTest(BaseAPIIntegrationTest):
|
|||
self.assertIn('Containers', res)
|
||||
self.assertIn('Images', res)
|
||||
self.assertIn('Debug', res)
|
||||
print(res)
|
||||
self.fail()
|
||||
|
||||
|
||||
class LoadConfigTest(BaseAPIIntegrationTest):
|
||||
|
|
|
@ -578,6 +578,9 @@ class PortsTest(unittest.TestCase):
|
|||
self.assertRaises(ValueError,
|
||||
lambda: split_port("localhost:80:"))
|
||||
|
||||
def test_split_port_empty_string(self):
|
||||
self.assertRaises(ValueError, lambda: split_port(""))
|
||||
|
||||
def test_build_port_bindings_with_one_port(self):
|
||||
port_bindings = build_port_bindings(["127.0.0.1:1000:1000"])
|
||||
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
|
||||
|
|
Loading…
Reference in New Issue