def test(self): main = TestedProgram('main') main.start_in_background() out = main.get_output() if out != '': return wrong('') sleep(0.15) out = main.get_output() if out != "Test\n": return wrong('') sleep(0.2) out = main.get_output() if out != "Test\nTest\n": return wrong('') main.stop() if not main.is_finished(): return wrong("") return correct()
def test(self): if '123.txt' in os.listdir('.'): if open('123.txt').read() == '12345': return correct() return wrong( 'There should be a file named "123.txt" with content "12345"')
def test(self): main = TestedProgram('main') main.set_return_output_after_execution(False) out = main.start() if len(out) != 0: return wrong("Output should be empty") out = main.get_output() if out != "Initial text\n": return wrong("Output is wrong") for i in range(2): if len(main.execute('')) != 0: return wrong("Output should be empty") out = main.get_output() if out != "1 to 2\n2 to 3\n": return wrong("Output is wrong") main.set_return_output_after_execution(True) if main.execute("") != "3 to 4\n": return wrong("Output should not be empty") if len(main.get_output()) != 0: return wrong( "get_output() should return an empty string at the end") return correct()
def test(self) -> CheckResult: create_files(self._test_case.files) # startThreads(testCase.getProcesses()) if Settings.do_reset_output: OutputHandler.reset_output() result = None try: result = self._test_runner.test(self) except BaseException as ex: self.set_error_in_test(ex) # stopThreads(testCase.getProcesses(), pool) delete_files(self._test_case.files) if result is None: self._check_errors() if isinstance(self._error_in_test, TestPassed): result = correct() if result is None: raise UnexpectedError("Result is None after testing") return result
def test(self): pr = TestedProgram('main') out1 = pr.start() if out1 != "Server started!\n": return wrong("") return correct()
def test(self): pr = TestedProgram('main') out1 = pr.start() if out1 != "Server started!\n": return wrong("") out1 = pr.execute("main") if out1 != "S1: main\n": return wrong("") pr.execute("main2") return correct()
def test(self): pr = TestedProgram('main') out1 = pr.start() if out1 != "Program started!\n": return wrong("") out3 = pr.execute("input1") if out3 != "S1: input1\n": return wrong("") out5 = pr.execute("input2") if out5 != "S2: input2\n": return wrong("") return correct()
def test(self): server = TestedProgram('main') server.start_in_background() sleep(0.05) out = server.get_output() if out != "Server started!\n": return wrong("") sleep(0.1) out = server.get_output() if out != "S1\n": return wrong("") sleep(0.2) out = server.get_output() if out != "S2\nS3\n": return wrong("") return correct()
def check(self, reply: str, attach: Any) -> CheckResult: if "Server stopped!\n" in reply: return correct() return wrong('')
def test(self): main = TestedProgram('main') main.start() return correct()
def test(self): return correct()
def generate(self) -> List[TestCase]: return [TestCase(dynamic_testing=lambda: correct())]