def testStdin(self): """Will write to subprocess.stdin.""" with self.assertRaises(subprocess.CalledProcessError) as cpe: bootstrap.call(['/bin/bash'], stdin='exit 92') self.assertEquals(92, cpe.exception.returncode)
def testCheckTrue(self): """Raise on non-zero exit codes if check is set.""" with self.assertRaises(subprocess.CalledProcessError) as cpe: bootstrap.call(FAIL, check=True) bootstrap.call(PASS, check=True)
def testCheckFalse(self): """Never raise when check is not set.""" bootstrap.call(FAIL, check=False) bootstrap.call(PASS, check=False)
def testOutput(self): """Output is returned when requested.""" cmd = ['/bin/bash', '-c', 'echo hello world'] self.assertEquals('hello world\n', bootstrap.call(cmd, output=True))
def testCheckDefault(self): """Default to check=True.""" with self.assertRaises(subprocess.CalledProcessError) as cpe: bootstrap.call(FAIL) bootstrap.call(PASS)
def testZombie(self): with self.assertRaises(subprocess.CalledProcessError) as cpe: # make a zombie bootstrap.call(['/bin/bash', '-c', 'A=$BASHPID && ( kill -STOP $A ) & exit 1'])
def testOutput(self): """Output is returned when requested.""" cmd = ['/bin/bash', '-c', 'echo hello world'] self.assertEquals( 'hello world\n', bootstrap.call(cmd, output=True))