def testbgcommandfailure1(self): """runbgcommand() should throw if executing the process fails.""" env = os.environ.copy() try: extutil.runbgcommand(["no_such_program", "arg1", "arg2"], env) self.fail("expected runbgcommand to fail with ENOENT") except OSError as ex: self.assertEqual(ex.errno, errno.ENOENT)
def testbgcommandfailure2(self): """runbgcommand() should throw if executing the process fails.""" env = os.environ.copy() try: extutil.runbgcommand([os.devnull, "arg1", "arg2"], env) self.fail("expected runbgcommand to fail with EACCES") except OSError as ex: self.assertEqual(ex.errno, errno.EACCES)
def testbgcommandnoblock(self): """runbgcommand() should return without waiting for the process to finish.""" env = os.environ.copy() start = time.time() extutil.runbgcommand(["sleep", "5"], env) end = time.time() if end - start >= 1.0: self.fail("runbgcommand() took took %s seconds, should have " "returned immediately" % (end - start))