Exemplo n.º 1
0
    def test_10_do_task__w_permission_denied_error(self):
        if os.getuid() == 0:
            print("Skip this test because you're root.")
            return

        # It seems that neighther 'subprocess.Popen("true",
        # cwd="/root").wait()' nor 'subprocess.Popen("cd /root && true",
        # shell=True).wait()' does not raise any exceptions these days:
        # task = SH.Task("true", workdir="/root", timeout=10)
        # task = SH.Task("cd /root && true", workdir="/root", timeout=10)

        task = SH.Task("touch /root/.bashrc", timeout=10)

        with self.assertRaises(SH.TaskError):
            SH.do_task(task, stop_on_error=True)
Exemplo n.º 2
0
    def test_10_do_task__w_permission_denied_error(self):
        if os.getuid() == 0:
            print("Skip this test because you're root.")
            return

        # It seems that neighther 'subprocess.Popen("true",
        # cwd="/root").wait()' nor 'subprocess.Popen("cd /root && true",
        # shell=True).wait()' does not raise any exceptions these days:
        # task = SH.Task("true", workdir="/root", timeout=10)
        # task = SH.Task("cd /root && true", workdir="/root", timeout=10)

        task = SH.Task("touch /root/.bashrc", timeout=10)

        with self.assertRaises(SH.TaskError):
            SH.do_task(task, stop_on_error=True)
Exemplo n.º 3
0
    def test_20_do_task__ignore_permission_denied_error(self):
        if os.getuid() == 0:
            print("Skip this test because you're root.")
            return

        task = SH.Task("touch /root/.bashrc", workdir="/root", timeout=10)
        self.assertNotEquals(SH.do_task(task, stop_on_error=False), 0)
Exemplo n.º 4
0
    def test_20_do_task__ignore_permission_denied_error(self):
        if os.getuid() == 0:
            print("Skip this test because you're root.")
            return

        task = SH.Task("touch /root/.bashrc", workdir="/root", timeout=10)
        self.assertNotEquals(SH.do_task(task, stop_on_error=False), 0)
Exemplo n.º 5
0
    def test_31_do_task__timeout__w_rc(self):
        task = SH.Task("sleep 10", timeout=1)

        self.assertNotEquals(SH.do_task(task, stop_on_error=False), 0)
Exemplo n.º 6
0
    def test_30_do_task__timeout(self):
        task = SH.Task("sleep 10", timeout=1)

        with self.assertRaises(SH.TaskError):
            SH.do_task(task)
Exemplo n.º 7
0
 def test_02_do_task__no_errors_but_not_return_0(self):
     task = SH.Task("false", timeout=10)
     self.assertNotEquals(SH.do_task(task, stop_on_error=False), 0)
Exemplo n.º 8
0
    def test_01_do_task__no_errors_but_not_return_0_and_exception_raised(self):
        task = SH.Task("false", timeout=10)

        with self.assertRaises(SH.TaskError):
            SH.do_task(task)
Exemplo n.º 9
0
 def test_00_do_task__no_errors(self):
     task = SH.Task("true", timeout=10)
     self.assertEquals(SH.do_task(task), 0)
Exemplo n.º 10
0
    def test_31_do_task__timeout__w_rc(self):
        task = SH.Task("sleep 10", timeout=1)

        self.assertNotEquals(SH.do_task(task, stop_on_error=False), 0)
Exemplo n.º 11
0
    def test_30_do_task__timeout(self):
        task = SH.Task("sleep 10", timeout=1)

        with self.assertRaises(SH.TaskError):
            SH.do_task(task)
Exemplo n.º 12
0
 def test_02_do_task__no_errors_but_not_return_0(self):
     task = SH.Task("false", timeout=10)
     self.assertNotEquals(SH.do_task(task, stop_on_error=False), 0)
Exemplo n.º 13
0
    def test_01_do_task__no_errors_but_not_return_0_and_exception_raised(self):
        task = SH.Task("false", timeout=10)

        with self.assertRaises(SH.TaskError):
            SH.do_task(task)
Exemplo n.º 14
0
 def test_00_do_task__no_errors(self):
     task = SH.Task("true", timeout=10)
     self.assertEquals(SH.do_task(task), 0)