From d8dd99b230f8b2f529c26a0c5d6065bfdf56374a Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Tue, 7 Sep 2021 00:08:37 +0100 Subject: [PATCH] testlib: Don't assume `docker port` output matches regex (cherry picked from commit 8cbbfaf3c153fb11cbceab4a7aa470c6fb4fe311) --- tests/testlib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/testlib.py b/tests/testlib.py index ee76a26d..8220a1f5 100644 --- a/tests/testlib.py +++ b/tests/testlib.py @@ -423,7 +423,10 @@ class DockerizedSshDaemon(object): def _get_container_port(self): s = subprocess__check_output(['docker', 'port', self.container_name]) 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': self.port = int(bport)