SCAutolib.models.log
This module provides a context manager, assert_log, designed for verifying
the presence of specific log entries in a file during test execution.
It allows for asserting that a given regular expression matches a newly generated log line within a specified log file.
Functions
- assert_log(path, expected_log)[source]
A context manager that asserts the creation of a new log line in a specified file that matches a given regular expression.
When entering the context, the log file’s pointer is moved to its end to ignore any existing logs. The code block within the
withstatement is then executed. Upon exiting the context (either normally or due to an exception), the function reads new log entries and attempts to find a match for theexpected_logregular expression.If no matching log is found among the newly generated entries, an exception is raised.
- Parameters:
- Yield:
None. This is a context manager, so it yields control to the
withblock.- Raises:
Exception – If no new log line matches the
expected_logregular expression by the time the context is exited.