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