Skip to content

Commit 7e8522b

Browse files
committed
smoketests: Make gathering container ports None-safe
1 parent 36f7ca2 commit 7e8522b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

smoketests/docker.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ def host_ports(self, docker) -> set[int]:
5757
"""
5858
host_ports = set()
5959
info = docker.inspect_container(self)
60-
for ports in info['NetworkSettings']['Ports'].values():
61-
for ip_and_port in ports:
62-
host_port = ip_and_port.get("HostPort")
63-
if host_port:
64-
host_ports.add(host_port)
60+
for ports in info.get('NetworkSettings', {}).get('Ports', {}).values():
61+
if ports:
62+
for ip_and_port in ports:
63+
host_port = ip_and_port.get("HostPort")
64+
if host_port:
65+
host_ports.add(host_port)
6566
return host_ports
6667

6768
def is_running(self, docker, ping_url: Callable[[int], str]) -> bool:

0 commit comments

Comments
 (0)