def test_run_halt_on_nonzero(self, m_subprocess): m_subprocess.Popen.side_effect = OSError(1, "foobar") s = Sultan() with self.assertRaises(OSError): s.foobar("-qux").run() try: s.foobar("-qux").run(halt_on_nonzero=False) except Exception: self.fail( "s.foobar('-qux').run(halt_on_nonzero=False) should not raise any errors.")
def test_run_halt_on_nonzero(self, m_subprocess): m_subprocess.Popen = mock.Mock() m_subprocess.Popen().communicate.side_effect = subprocess.CalledProcessError(1, "foobar") s = Sultan() with self.assertRaises(subprocess.CalledProcessError): s.foobar("-qux").run() try: s.foobar("-qux").run(halt_on_nonzero=False) except Exception as e: self.fail( "s.foobar('-qux').run(halt_on_nonzero=False) should not raise any errors.")
def test_run_halt_on_nonzero(self, m_subprocess): m_subprocess.check_output.side_effect = subprocess.CalledProcessError( 1, "foobar") s = Sultan() with self.assertRaises(subprocess.CalledProcessError): s.foobar("-qux").run() try: s.foobar("-qux").run(halt_on_nonzero=False) except Exception, e: self.fail( "s.foobar('-qux').run(halt_on_nonzero=False) should not raise any errors." )