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