def test_run_executable_does_not_exist(self): """ Executable.run() fails if the executable does not exist. """ filename = self._resolve_executable("does-not-exist") exe = Executable(filename) with self.assertRaises(ExecutableNotFoundError): exe.run()
def test_run(self): """ Executable.run() runs the command and returns nothing. """ filename = self._write_executable("script") exe = Executable(filename, {"SPAM": "eggs"}) with tempfile.NamedTemporaryFile() as outfile: exe.run("x", "-y", "z", stdout=outfile) outfile.seek(0) out = outfile.read() self.assertTrue(out.startswith("x -y z\n")) self.assertIn("SPAM=eggs\n", out)