Skip to content

Commit

Permalink
Handle unicode in output correctly in tests under py2
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterv committed Oct 16, 2016
1 parent fba0462 commit 012172c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def assertSuccess(self, args, expected_output_lines=None, from_prefix=True):
args[0] += ".bat"

process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = process.communicate()[0].decode("UTF-8")
output = process.communicate()[0]

if process.returncode != 0:
raise AssertionError("Error running command '{}': code {}, output:\n{}".format(
Expand All @@ -39,6 +39,8 @@ def assertSuccess(self, args, expected_output_lines=None, from_prefix=True):
actual_output_lines = output.splitlines()

for expected_output_line in expected_output_lines:
expected_output_line = expected_output_line.encode("UTF-8")

if not any(expected_output_line in actual_output_line for actual_output_line in actual_output_lines):
raise AssertionError("Expected to see '{}' in output of command '{}', got output:\n{}".format(
expected_output_line, " ".join(args), output))
Expand Down

0 comments on commit 012172c

Please sign in to comment.