Beispiel #1
0
    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")
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 def test__repr_doesnt_fail(self):
     representation = repr(local.execute("echo hello", shell=True))
     self.assertGreater(len(representation), 0)
Beispiel #6
0
 def test__invalid_kwargs(self):
     with self.assertRaises(TypeError):
         local.execute("command", bla=2, bloop=3)
Beispiel #7
0
 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()
Beispiel #8
0
 def test__ignore_exit_code(self):
     result = local.execute("false", shell=True)
     self.assertEquals(result.get_returncode(), self.FALSE_RETURN_CODE)
Beispiel #9
0
    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")
Beispiel #10
0
 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)
Beispiel #11
0
 def test__repr_doesnt_fail(self):
     representation = repr(local.execute("echo hello", shell=True))
     self.assertGreater(len(representation), 0)
Beispiel #12
0
 def test__invalid_kwargs(self):
     with self.assertRaises(TypeError):
         local.execute("command", bla=2, bloop=3)
Beispiel #13
0
 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()
Beispiel #14
0
 def test__ignore_exit_code(self):
     result = local.execute("false", shell=True)
     self.assertEquals(result.get_returncode(), self.FALSE_RETURN_CODE)