def test_processrunner_leak_check(self): limit = 100 command = ["echo", "bonjour"] openFilesCommand = ["lsof", "-p", str(os.getpid())] openFilesStart = runCommand(openFilesCommand, returnAllContent=True) for i in range(limit): self.spinner.spin() with ProcessRunner(command) as proc: discard = proc.collectLines() openFilesEnd = runCommand(openFilesCommand, returnAllContent=True) self.assertEqual( len(openFilesStart), len(openFilesEnd), "Open file count changed: Start {} to End {}".format( len(openFilesStart), len(openFilesEnd)))
def test_processrunner_runCommand_emoji_check_content(self): textIn = "😂" * 10 command = ["echo", textIn] returnData = runCommand(command, returnAllContent=True) textOut = returnData[1][0] self.assertEqual( textIn, textOut, "Returned text not the same: in '{}', out '{}'".format( textIn, textOut))
def test_processrunner_runCommand_check_one_return_combined(self): returnCodeIn = 1 command = [ self.sampleCommandPath, "--lines", "0", "--return-code", str(returnCodeIn) ] returnCodeOut = runCommand(command, returnAllContent=True)[0] self.assertEqual( returnCodeIn, returnCodeOut, "Return code from runCommand not returning {}, instead {}".format( returnCodeIn, returnCodeOut))
def test_processrunner_runCommand_check_twofivefive_return(self): returnCodeIn = 255 command = [ self.sampleCommandPath, "--lines", "0", "--return-code", str(returnCodeIn) ] returnCodeOut = runCommand(command) self.assertEqual( returnCodeIn, returnCodeOut, "Return code from runCommand not returning {}, instead {}".format( returnCodeIn, returnCodeOut))