def METHOD_NAME(self, level: str, message: str) -> None:
    """Assert that the Python logger has received a message with the given level and text."""
    try:
        assert self.caplog.records, 'Expected a log message'
        record = self.caplog.records[0]
        print(record.levelname, record.message)
        assert record.levelname.strip() == level, f'Expected "{level}" but got "{record.levelname}"'
        assert record.message.strip() == message, f'Expected "{message}" but got "{record.message}"'
    finally:
        self.caplog.records.clear()