def test_log(self): gLog.open("2", 10) gLog.print( """ Expected output: Interleaved output from multiple threads Each thread logs (a) when it is starting (b) multiple lines of output (c) when it has ended There should be NO BLANK LINES in the log and each line should contain output from a single thread. The line '....MIDPOINT...' appears half way through. In the first half lines are about 90 characters long. In the second half lines are twice as long. """ ) for digit in range(10): PrintManyLinesToLog(str(digit)).start() sleep(2) gLog.flush() gLog.print("...................... MIDPOINT.........................") for digit in range(10): PrintManyLinesToLog(str(digit) + str(digit) + str(digit)).start() sleep(5) gLog.close() raise Exception("EXCEPTION EXPECTED: Check correctness of output in file log_test.txt")
def test_assertions(self): gLog.open("1") self.assertRaises(AssertionError, gLog.print, 3) # trying to print a non string gLog.close() self.assertRaises(AssertionError, gLog.open, 1, 40) # name is not a string self.assertRaises(AssertionError, gLog.open, "a", "cat") # flushFrequency is not an integer self.assertRaises(AssertionError, gLog.open, "a", 2.5) # flushFrequency is not an integer self.assertRaises(AssertionError, gLog.open, "a", -2) # flushFrequency is < 0
from Log import gLog from StartAndKill import StartAndKill def raw_input(st): return input(st) if __name__ == "__main__": gLog.open('1', 5) sak = StartAndKill(mode='testing') sak.start("simulator") sak.start("controller", ip = "127.0.0.1", port = "1234", trace = "yes") sak.start("ut4", ip = "127.0.0.1", port = "1234") sak.start("RBLDisplay", ip = "127.0.0.1", port = "1235") sak.start("adminthrottle", ip = "127.0.0.1", port = "1235", layoutFile = "layout.xml", logs = "no") print("\n") sak.start("controller", trace = "no") sak.start("ut4", port = "1236") sak.start("RBLDisplay", ip = "127.1.1.1") sak.start("adminthrottle", ip = "127.0.0.1", port = "1234", logs = "yes") print("\n") sak.kill("sim") sak.kill("cont") sak.kill("ut4") sak.kill("RBL") sak.kill("admin") sak.kill() sak.kill("all") gLog.close()