testlib: Don't assume `docker port` output matches regex

(cherry picked from commit 8cbbfaf3c1)
pull/863/head
Alex Willmer 3 years ago
parent 937a003a91
commit d8dd99b230

@ -423,7 +423,10 @@ class DockerizedSshDaemon(object):
def _get_container_port(self): def _get_container_port(self):
s = subprocess__check_output(['docker', 'port', self.container_name]) s = subprocess__check_output(['docker', 'port', self.container_name])
for line in s.decode().splitlines(): for line in s.decode().splitlines():
dport, proto, baddr, bport = self.PORT_RE.match(line).groups() m = self.PORT_RE.match(line)
if not m:
continue
dport, proto, _, bport = m.groups()
if dport == '22' and proto == 'tcp': if dport == '22' and proto == 'tcp':
self.port = int(bport) self.port = int(bport)

Loading…
Cancel
Save