Problem: caplog not capturing logging statements in a test

Solution: Put the function execution in the `caplog` context
This commit is contained in:
z-bowen 2018-08-29 15:14:17 +02:00
parent e163547a7e
commit 8f01e1c4e8

View File

@ -156,8 +156,8 @@ def test_upsert_validator_show(caplog, ongoing_election, b, priv_validator_path,
show_args = Namespace(action='show', show_args = Namespace(action='show',
election_id=election_id) election_id=election_id)
run_upsert_validator_show(show_args, b)
with caplog.at_level(logging.INFO): with caplog.at_level(logging.INFO):
assert caplog.records.pop().msg == \ run_upsert_validator_show(show_args, b)
f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}' msg = caplog.records.pop().msg
assert msg == f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}'
print("I am here")