Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Use caplog to verify log calls
Logger asserts are error-prone, because they assert calls, not actual messages. The caplog fixture is Pytest-native way to test logs. This makes integration-level unit tests easier to add. For the caplog fixture to work on Python 2.6 (RHEL 6), pytest_catchlog needs to be installed. On more recent version of python, the fixture is included in Pytest. pytest_catchlog caused pidfile write tests to fail. The fixture itself calls os.getpid, interfering with the patch. Every log message makes a getpid call that is recorded in the patch. assert_not_called patches then stopped working. Fixed by removing the os.getpid patch. The original function is safe to use. test_write_pidfile_not_called verifies several calls among which write_to_disk is the important one, not getpid. Card IDs: * CCT-774 * CCT-963 * CCT-1084 Signed-off-by: Štěpán Tomsa <[email protected]>
- Loading branch information