def test__sync_execute_stderr(self): produce_stderr_command = ["-c", "import sys;sys.stderr.write('hello')"] produce_stderr_command.insert(0,sys.executable) result = local.execute(produce_stderr_command) self.assertEquals(result.get_stderr(), "hello")
def test__execute_with_env(self): key = b"some_key" value = b"some_value" output = local.execute("set", shell=True, env={ key: value }).get_stdout() self.assertIn(key, output) self.assertIn(value, output)
def test__execute_with_env(self): key = "some_key" value = "some_value" output = local.execute("set", shell=True, env={key:value}).get_stdout() self.assertIn(key, output) self.assertIn(value, output)
def test__sync_execute_shell(self): result = local.execute("echo hello", shell=True) self.assertEquals(result.get_returncode(), 0) self.assertEquals(result.get_stderr(), "") newline = "\r\n" if os.name == 'nt' else "\n" self.assertEquals(result.get_stdout(), "hello%s" % newline)
def test__repr_doesnt_fail(self): representation = repr(local.execute("echo hello", shell=True)) self.assertGreater(len(representation), 0)
def test__invalid_kwargs(self): with self.assertRaises(TypeError): local.execute("command", bla=2, bloop=3)
def test__timeout_sync(self): with self.assertRaises(CommandTimeout) as caught: local.execute("sleep 100", timeout=1, shell=True) self.assertFalse(caught.exception.result.is_finished()) caught.exception.result.kill()
def test__ignore_exit_code(self): result = local.execute("false", shell=True) self.assertEquals(result.get_returncode(), self.FALSE_RETURN_CODE)
def test__sync_execute_stderr(self): produce_stderr_command = ["-c", "import sys;sys.stderr.write('hello')"] produce_stderr_command.insert(0, sys.executable) result = local.execute(produce_stderr_command) self.assertEquals(result.get_stderr(), b"hello")
def test__sync_execute_shell(self): result = local.execute("echo hello", shell=True) self.assertEquals(result.get_returncode(), 0) self.assertEquals(result.get_stderr(), b"") newline = b"\r\n" if os.name == 'nt' else b"\n" self.assertEquals(result.get_stdout(), b"hello" + newline)