Log a detailed error message to discover why MockServer is not working

This commit is contained in:
Adrián Chaves 2020-06-03 08:20:50 +02:00
parent 63091fbdce
commit a3eb069b84
1 changed files with 6 additions and 1 deletions

View File

@ -42,7 +42,12 @@ sys.exit(mitmdump())
],
stdout=PIPE, env=get_testenv())
line = self.proc.stdout.readline().decode('utf-8')
host_port = re.search(r'listening at http://([^:]+:\d+)', line).group(1)
pattern = r'listening at http://([^:]+:\d+)'
match = re.search(pattern, line)
if not match:
raise RuntimeError('Could not find {} in stdout line {}'
.format(repr(pattern), repr(line)))
host_port = match.group(1)
address = 'http://%s:%s@%s' % (self.auth_user, self.auth_pass, host_port)
return address