Skip to content

Commit

Permalink
test_cli: workaround pytest log indentation behaviour change
Browse files Browse the repository at this point in the history
pytest 4.6.x started indenting trailing lines in log messages, which
meant that our matching in the affected test stopped working once we
introduced newlines into the relevant log output in canonical#973.

If focal moves onto pytest 5.x before release, then we can remove this
workaround.

The upstream issue is pytest-dev/pytest#5515
  • Loading branch information
OddBloke committed Feb 6, 2020
1 parent 20e6822 commit 5b736b4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions uaclient/tests/test_cli.py
Expand Up @@ -289,6 +289,14 @@ def test_user_facing_error_handled_gracefully(
assert "" == out
assert "{}\n".format(expected_msg) == err
error_log = caplog_text()
# pytest 4.6.x started indenting trailing lines in log messages, which
# meant that our matching here stopped working once we introduced
# newlines into this log output in #973. (If focal moves onto pytest
# 5.x before release, then we can remove this workaround.) The
# upstream issue is https://github.com/pytest-dev/pytest/issues/5515
error_log = "\n".join(
[line.strip() for line in error_log.splitlines()]
)
assert expected_msg in error_log
assert "Traceback (most recent call last):" in error_log

Expand Down

0 comments on commit 5b736b4

Please sign in to comment.