def testConsolePrint(self): if sys.version_info[0] == 3: tmp_file = io.StringIO() stdout = sys.stdout sys.stdout = tmp_file try: rinterface.consolePrint('haha') except Exception as e: sys.stdout = stdout raise e sys.stdout = stdout tmp_file.flush() tmp_file.seek(0) self.assertEqual('haha', ''.join(s for s in tmp_file).rstrip()) tmp_file.close() else: # no need to test which Python 2, only 2.7 supported tmp_file = tempfile.NamedTemporaryFile() stdout = sys.stdout sys.stdout = tmp_file try: rinterface.consolePrint('haha') except Exception as e: sys.stdout = stdout raise e sys.stdout = stdout tmp_file.flush() tmp_file.seek(0) self.assertEqual('haha', ''.join(s.decode() for s in tmp_file)) tmp_file.close()
def testConsolePrint(self): tmp_file = tempfile.NamedTemporaryFile() stdout = sys.stdout sys.stdout = tmp_file try: rinterface.consolePrint('haha') except Exception, e: sys.stdout = stdout raise e
def testConsolePrint(self): tmp_file = io.StringIO() stdout = sys.stdout sys.stdout = tmp_file try: rinterface.consolePrint('haha') finally: sys.stdout = stdout tmp_file.flush() tmp_file.seek(0) self.assertEqual('haha', ''.join(s for s in tmp_file).rstrip()) tmp_file.close()
def testConsolePrint(self): if sys.version_info[0] == 3: tmp_file = io.StringIO() stdout = sys.stdout sys.stdout = tmp_file try: rinterface.consolePrint('haha') except Exception, e: sys.stdout = stdout raise e sys.stdout = stdout tmp_file.flush() tmp_file.seek(0) self.assertEqual('haha', ''.join(s for s in tmp_file).rstrip()) tmp_file.close()
rinterface.consolePrint('haha') except Exception, e: sys.stdout = stdout raise e sys.stdout = stdout tmp_file.flush() tmp_file.seek(0) self.assertEqual('haha', ''.join(s for s in tmp_file).rstrip()) tmp_file.close() else: # no need to test which Python 2, only 2.7 supported tmp_file = tempfile.NamedTemporaryFile() stdout = sys.stdout sys.stdout = tmp_file try: rinterface.consolePrint('haha') except Exception, e: sys.stdout = stdout raise e sys.stdout = stdout tmp_file.flush() tmp_file.seek(0) self.assertEqual('haha', ''.join(s.decode() for s in tmp_file)) tmp_file.close() def testCallErrorWhenEndedR(self): if sys.version_info[0] == 2 and sys.version_info[1] < 6: self.assertTrue(False) # cannot be tested with Python < 2.6 return None import multiprocessing