mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Clarify Failing Test Message; Search for Entire Log Line in caplog
This commit is contained in:
parent
071a65fb10
commit
a467c04d04
1 changed files with 7 additions and 10 deletions
|
@ -53,22 +53,19 @@ def test_issue_64169(caplog):
|
|||
log=None # Regression will cause this function call to throw
|
||||
# an AttributeError
|
||||
)
|
||||
except AttributeError:
|
||||
except AttributeError as exc:
|
||||
# Observed behavior in #64169
|
||||
assert False
|
||||
pytest.fail(
|
||||
'Regression on #64169: pip_state.installed seems to be throwing an unexpected AttributeException: '
|
||||
f'{exc}'
|
||||
)
|
||||
except:
|
||||
# Something went wrong, but it isn't what's being tested for here.
|
||||
return
|
||||
|
||||
# Take 64169 further and actually confirm that the exception from pip.list got logged.
|
||||
exc_msg_present = False
|
||||
for log_line in caplog.messages:
|
||||
# The exception must be somewhere in the log, but may optionally not be on a line by itself.
|
||||
if exception_message in log_line:
|
||||
exc_msg_present = True
|
||||
break
|
||||
|
||||
assert exc_msg_present
|
||||
assert 'Pre-caching of PIP packages during states.pip.installed failed by exception ' \
|
||||
f'from pip.list: {exception_message}' in caplog.messages
|
||||
|
||||
# Confirm that the state continued to install the package as expected.
|
||||
# Only check the 'pkgs' parameter of pip.install
|
||||
|
|
Loading…
Add table
Reference in a new issue