def testSetFlushConsole(self): flush = {'count': 0} def f(): flush['count'] = flush['count'] + 1 rinterface.set_flushconsole(f) self.assertEquals(rinterface.get_flushconsole(), f) rinterface.baseenv.get("flush.console")() self.assertEquals(1, flush['count']) rinterface.set_writeconsole(rinterface.consoleFlush)
def testFlushConsoleWithError(self): def f(prompt): raise Exception("Doesn't work.") rinterface.set_flushconsole(f) tmp_file = tempfile.NamedTemporaryFile() stderr = sys.stderr sys.stderr = tmp_file try: res = rinterface.baseenv.get("flush.console")() except Exception, e: sys.stderr = stderr raise e