Beispiel #1
0
    def test_glob_warning(self):
        from pbs import ls
        from glob import glob
        import warnings

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            ls(glob("ofjaoweijfaowe"))

            self.assertTrue(len(w) == 1)
            self.assertTrue(issubclass(w[-1].category, UserWarning))
            self.assertTrue("glob" in str(w[-1].message))
Beispiel #2
0
    def test_glob_warning(self):
        from pbs import ls
        from glob import glob
        import warnings

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            ls(glob("ofjaoweijfaowe"))

            self.assertTrue(len(w) == 1)
            self.assertTrue(issubclass(w[-1].category, UserWarning))
            self.assertTrue("glob" in str(w[-1].message))
Beispiel #3
0
    def test_err_redirection(self):
        import tempfile
        from pbs import time, ls

        file_obj = tempfile.TemporaryFile()

        with time(_with=True):
            ls(_err=file_obj)
        
        file_obj.seek(0)
        actual_out = file_obj.read()

        self.assertTrue(len(actual_out) != 0)
        file_obj.close()
Beispiel #4
0
    def test_bake_args_come_first(self):
        from pbs import ls
        ls = ls.bake(full_time=True)

        ran = ls("-la").command_ran
        ft = ran.index("full-time")
        self.assertTrue("-la" in ran[ft:])
Beispiel #5
0
 def test_composition(self):
     from pbs import ls, wc
     c1 = int(wc(ls("-A1"), l=True))
     c2 = len(os.listdir("."))
     if c1 != c2:
         with open("/tmp/fail", "a") as h: h.write("F**K\n")
     self.assertEqual(c1, c2)
Beispiel #6
0
 def test_bake_args_come_first(self):
     from pbs import ls
     ls = ls.bake(full_time=True)
     
     ran = ls("-la").command_ran
     ft = ran.index("full-time")
     self.assertTrue("-la" in ran[ft:]) 
Beispiel #7
0
 def test_composition(self):
     from pbs import ls, wc
     c1 = int(wc(ls("-A1"), l=True))
     c2 = len(os.listdir("."))
     if c1 != c2:
         with open("/tmp/fail", "a") as h:
             h.write("F**K\n")
     self.assertEqual(c1, c2)
Beispiel #8
0
 def test_command_wrapper(self):
     from pbs import Command, which
     
     ls = Command(which("ls"))
     wc = Command(which("wc"))
     
     c1 = int(wc(ls(A=True), l=True))
     c2 = len(os.listdir("."))
     self.assertEqual(c1, c2)
Beispiel #9
0
    def test_command_wrapper(self):
        from pbs import Command, which

        ls = Command(which("ls"))
        wc = Command(which("wc"))

        c1 = int(wc(ls("-A1"), l=True))
        c2 = len(os.listdir("."))

        self.assertEqual(c1, c2)
Beispiel #10
0
    def test_out_redirection(self):
        import tempfile
        from pbs import ls

        file_obj = tempfile.TemporaryFile()
        out = ls(_out=file_obj)

        file_obj.seek(0)
        actual_out = file_obj.read()
        file_obj.close()

        self.assertTrue(len(actual_out) != 0)
Beispiel #11
0
    def test_out_redirection(self):
        import tempfile
        from pbs import ls

        file_obj = tempfile.TemporaryFile()
        out = ls(_out=file_obj)

        file_obj.seek(0)
        actual_out = file_obj.read()
        file_obj.close()

        self.assertTrue(len(actual_out) != 0)
Beispiel #12
0
    def test_err_redirection(self):
        import tempfile
        from pbs import time, ls

        file_obj = tempfile.TemporaryFile()

        with time(_with=True):
            out = ls(_err=file_obj)

        file_obj.seek(0)
        actual_out = file_obj.read()
        file_obj.close()

        self.assertTrue(len(actual_out) != 0)
Beispiel #13
0
 def test_ok_code(self):
     from pbs import ls, ErrorReturnCode_2
     
     self.assertRaises(ErrorReturnCode_2, ls, "/aofwje/garogjao4a/eoan3on")
     ls("/aofwje/garogjao4a/eoan3on", _ok_code=2)
     ls("/aofwje/garogjao4a/eoan3on", _ok_code=[2])
Beispiel #14
0
 def test_with_context(self):
     from pbs import time, ls
     with time:
         out = ls().stderr
     self.assertTrue("pagefaults" in out)
Beispiel #15
0
    def test_err_to_out(self):
        from pbs import time, ls
        with time(_with=True):
            out = ls(_err_to_out=True)

        self.assertTrue("pagefaults" in out)
Beispiel #16
0
 def test_with_context_args(self):
     from pbs import time, ls
     with time(verbose=True, _with=True):
         out = ls().stderr
     self.assertTrue("Voluntary context switches" in out)
Beispiel #17
0
 def test_with_context(self):
     from pbs import time, ls
     with time:
         out = ls().stderr
     self.assertTrue("pagefaults" in out)
Beispiel #18
0
 def test_with_context_args(self):
     from pbs import time, ls
     with time(verbose=True, _with=True):
         out = ls().stderr
     self.assertTrue("Voluntary context switches" in out)
Beispiel #19
0
 def test_composition(self):
     from pbs import ls, wc
     c1 = int(wc(ls(A=True), l=True))
     c2 = len(os.listdir("."))
     self.assertEqual(c1, c2)
Beispiel #20
0
#!/usr/bin/env python
from pbs import ls, wc


def p(val, *fns):
    for fn in fns:
        val = fn(val)
    return val


print p(ls(), wc())
Beispiel #21
0
    def test_ok_code(self):
        from pbs import ls, ErrorReturnCode_2

        self.assertRaises(ErrorReturnCode_2, ls, "/aofwje/garogjao4a/eoan3on")
        ls("/aofwje/garogjao4a/eoan3on", _ok_code=2)
        ls("/aofwje/garogjao4a/eoan3on", _ok_code=[2])
Beispiel #22
0
#!/usr/bin/env python
from pbs import ls, wc

def p(val, *fns):
    for fn in fns:
        val = fn(val)
    return val

print p(ls(), wc())
Beispiel #23
0
    def test_err_to_out(self):
        from pbs import time, ls
        with time(_with=True):
            out = ls(_err_to_out=True)

        self.assertTrue("pagefaults" in out)