def test_make_error_log_records_generates_output_logs_for_called_process_error( ): logs = tuple( module.make_error_log_records( 'Error', subprocess.CalledProcessError(1, 'ls', 'error output'))) assert {log.levelno for log in logs} == {logging.CRITICAL} assert any(log for log in logs if 'error output' in str(log))
def test_make_error_log_records_generates_output_logs_for_called_process_error( ): flexmock(module).should_receive('log_record').replace_with(dict) flexmock(module.logger).should_receive('getEffectiveLevel').and_return( logging.WARNING) logs = tuple( module.make_error_log_records( 'Error', subprocess.CalledProcessError(1, 'ls', 'error output'))) assert {log['levelno'] for log in logs} == {logging.CRITICAL} assert any(log for log in logs if 'error output' in str(log))
def test_make_error_log_records_generates_nothing_for_other_error(): flexmock(module).should_receive('log_record').replace_with(dict) logs = tuple(module.make_error_log_records('Error', KeyError())) assert logs == ()
def test_make_error_log_records_generates_logs_for_os_error(): flexmock(module).should_receive('log_record').replace_with(dict) logs = tuple(module.make_error_log_records('Error', OSError())) assert {log['levelno'] for log in logs} == {logging.CRITICAL}
def test_make_error_log_records_generates_nothing_for_other_error(): logs = tuple(module.make_error_log_records('Error', KeyError())) assert logs == ()
def test_make_error_log_records_generates_logs_for_os_error(): logs = tuple(module.make_error_log_records('Error', OSError())) assert {log.levelno for log in logs} == {logging.CRITICAL}
def test_make_error_log_records_generates_output_logs_for_message_only(): logs = tuple(module.make_error_log_records('Error')) assert {log.levelno for log in logs} == {logging.CRITICAL}