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 authored and patriciadomin committed Feb 27, 2020
1 parent 3a9a17e commit 21f901e
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 21f901e

Please sign in to comment.