def test_print_result_sigpipe(self): """ Test BrokenPipe silent handling When executing 'cli_cmd | grep -m1' code may raise a BrokenPipe error message. We just want it to be silent """ result = {'ret': 0} with patch('%s.print' % BUILTIN) as mock_print: # Silent BrokenPipe mock_print.side_effect = IOError(32, 'Broken pipe') common.print_result(result) # Should raise other errors mock_print.side_effect = IOError(28, 'No space left on device') self.assertRaises(IOError, common.print_result, result)
def test_print_result(self): """verify that print_result can handle None results""" self.assertIsNone(print_result(None))