Beispiel #1
0
 def test_cmd(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     out, err = run_cmd("dir", shell=True, wait=True)
     assert len(out) > 0
     out, err = run_cmd("dir *.pyc", shell=True, wait=True)
     assert len(out) > 0
Beispiel #2
0
    def test_run_cmd_1(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        cmd = "set" if sys.platform.startswith("win") else "env"
        fLOG("##########")
        out1, err = run_cmd(cmd, wait=True, fLOG=fLOG)
        fLOG("##########")
        out2, err = run_cmd(cmd, wait=True, communicate=False, fLOG=fLOG)
        fLOG("##########")
        self.maxDiff = None
        self.assertEqual(out1.strip(), out2.strip())
Beispiel #3
0
    def test_run_cmd_simple(self):
        fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")

        cmd = "dir ."
        out1, err = run_cmd(cmd, wait=True, fLOG=fLOG)
        out2, err = run_cmd(cmd, wait=True, communicate=False, fLOG=fLOG)

        fLOG("***", out1)
        fLOG("***", out2)

        out3, err = run_cmd(cmd, wait=True, communicate=True, fLOG=fLOG)
        fLOG("***", out3)

        out, err = skip_run_cmd(cmd, wait=True)
        assert len(out) == 0
        assert len(err) == 0
Beispiel #4
0
 def test_cmd_communicate(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     out, err = run_cmd("dir", wait=True, communicate=True)
     assert len(out) > 0
Beispiel #5
0
    def test_run_cmd_more(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        cmd = "more " + os.path.abspath(__file__)

        try:
            run_cmd(cmd, wait=True, communicate=False,
                    tell_if_no_output=600, fLOG=fLOG, sin="\n\n\n" * 100)
        except:
            pass

        out, err = run_cmd(cmd, wait=True, communicate=True,
                           fLOG=fLOG, sin="\n\n\n" * 100)
        assert len(out) > 10
        assert len(err) == 0
Beispiel #6
0
    def test_run_cmd_timeout(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if __name__ == "__main__":
            cmd = "more"
            out, err = run_cmd(cmd, wait=True, fLOG=fLOG,
                               tell_if_no_output=1, communicate=False, timeout=3)
            fLOG(out)
            fLOG(err)
            assert "Process killed" in err
Beispiel #7
0
    def test_run_cmd_2(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        cmd = "set" if sys.platform.startswith("win") else "env"

        out3, err = run_cmd(
            cmd, wait=True, communicate=False, tell_if_no_output=600, fLOG=fLOG)
        fLOG("***", out3)

        out, err = skip_run_cmd(cmd, wait=True)
        assert len(out) == 0
        assert len(err) == 0
        counts = dict(out=[], err=[])

        def stop_running_if(out, err, counts=counts):
            if out:
                counts["out"].append(out)
            if err:
                counts["err"].append(err)

        out4, err = run_cmd(
            cmd, wait=True, communicate=False, tell_if_no_output=600,
            stop_running_if=stop_running_if, fLOG=fLOG)
        fLOG("***", out3)

        out, err = skip_run_cmd(cmd, wait=True)
        assert len(out) == 0
        assert len(err) == 0
        self.maxDiff = None
        self.assertEqual(out3.strip(), out4.strip())
        assert len(counts["out"]) > 0
        if len(counts["err"]) > 0:
            raise Exception(counts["err"])