Skip to content

Commit bc5bcda

Browse files
author
billou
committed
convert_service_ports takes only a dict as param
Signed-off-by: billou <[email protected]>
1 parent a365202 commit bc5bcda

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

docker/types/services.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,9 @@ def __init__(self, mode=None, ports=None):
560560

561561

562562
def convert_service_ports(ports):
563-
if isinstance(ports, list):
564-
return ports
565563
if not isinstance(ports, dict):
566564
raise TypeError(
567-
'Invalid type for ports, expected dict or list'
565+
'Invalid type for ports, expected dict'
568566
)
569567

570568
result = []

tests/unit/dockertypes_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,9 @@ def test_convert_service_ports_multiple(self):
491491
} in converted_ports
492492

493493
assert len(converted_ports) == 3
494+
495+
def test_convert_service_ports_wrong_ports_type(self):
496+
ports = 'ports_as_string'
497+
498+
with pytest.raises(TypeError):
499+
convert_service_ports(ports)

0 commit comments

Comments
 (0)