mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Fix functional tests' '--capture' on Python 3
None of the commands' output is ever treated as binary, so we can just always decode it as text. Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
committed by
André Roth
parent
fb3436b23d
commit
b5bf2cbcda
@@ -248,14 +248,14 @@ class BaseTest(object):
|
||||
for cmd in self.fixtureCmds:
|
||||
output = self.run_cmd(cmd)
|
||||
print("fixture Output:\n")
|
||||
for line in output.decode("utf-8").split("\n"):
|
||||
for line in output.split("\n"):
|
||||
print(f" {line}")
|
||||
|
||||
def sort_lines(self, output):
|
||||
return "\n".join(sorted(self.ensure_utf8(output).split("\n")))
|
||||
|
||||
def run(self):
|
||||
output = self.run_cmd(self.runCmd, self.expectedCode).decode("utf-8")
|
||||
output = self.run_cmd(self.runCmd, self.expectedCode)
|
||||
if self.sortOutput:
|
||||
output = self.sort_lines(output)
|
||||
self.output = self.output_processor(output)
|
||||
@@ -289,6 +289,8 @@ class BaseTest(object):
|
||||
proc = self._start_process(command, stdout=subprocess.PIPE)
|
||||
raw_output, _ = proc.communicate()
|
||||
|
||||
raw_output = raw_output.decode("utf-8")
|
||||
|
||||
returncodes = [proc.returncode]
|
||||
is_aptly_command = False
|
||||
if isinstance(command, str):
|
||||
@@ -300,12 +302,12 @@ class BaseTest(object):
|
||||
if is_aptly_command:
|
||||
# remove the last two rows as go tests always print PASS/FAIL and coverage in those
|
||||
# two lines. This would otherwise fail the tests as they would not match gold
|
||||
match = re.search(r"EXIT: (\d)\n.*\n.*coverage: .*", raw_output.decode("utf-8"))
|
||||
if match is None:
|
||||
raise Exception("no matches found in output '%s'" % raw_output.decode("utf-8"))
|
||||
matches = re.findall(r"((.|\n)*)EXIT: (\d)\n.*\ncoverage: .*", raw_output)
|
||||
if not matches:
|
||||
raise Exception("no matches found in output '%s'" % raw_output)
|
||||
|
||||
output = match.string[:match.start()].encode()
|
||||
returncodes.append(int(match.group(1)))
|
||||
output, _, returncode = matches[0]
|
||||
returncodes.append(int(returncode))
|
||||
else:
|
||||
output = raw_output
|
||||
|
||||
@@ -356,7 +358,7 @@ class BaseTest(object):
|
||||
raise
|
||||
|
||||
def check_cmd_output(self, command, gold_name, match_prepare=None, expected_code=0):
|
||||
output = self.run_cmd(command, expected_code=expected_code).decode("utf-8")
|
||||
output = self.run_cmd(command, expected_code=expected_code)
|
||||
try:
|
||||
self.verify_match(self.get_gold(gold_name), output, match_prepare)
|
||||
except: # noqa: E722
|
||||
|
||||
Reference in New Issue
Block a user