def testBasic(self): """See if it works at all""" try: self._writeAndFlush(self.source, "d,0,1") result = runrepl.edit_output(self.fn_prefix) # print "result is", pprint.pformat(result) except Exception, e: self.fail(str(e))
def testCursorCmdStrip(self): """multiline cursor commands""" s = """sage: [0mversion() [0;31m[0m'Sage Version 6.1.1, Release Date: 2014-02-04' [0;34m""" try: self._writeAndFlush(s, "d,0,1") # print "self.fn_prefix is",self.fn_prefix result = runrepl.edit_output(self.fn_prefix, True) print "result is", pprint.pformat(result) except Exception, e: self.fail(str(e))
class edit_outputtest(unittest.TestCase): """Test the edit_output routine """ # source to edit source = "0123456789\nabcdef\nkkmm" # File names fn_prefix = 'runrepl_test_testfile' fn_output = fn_prefix + '.' + runrepl.UNEDITED_OUTPUT_EXTENSION fn_edits = fn_prefix + '.' + runrepl.EDITS_EXTENSION fn_result = fn_prefix + '.' + runrepl.RESULT_EXTENSION def _writeAndFlush(self, source, edits): """Take in strings to write to source file and edit command file, opens, writes and flushes, and closes. source string edits string """ f_output = open(self.fn_output, 'w') f_output.write(source) f_output.flush() f_output.close() f_edits = open(self.fn_edits, 'w') f_edits.write(edits) f_edits.flush() f_edits.close() def testBasic(self): """See if it works at all""" try: self._writeAndFlush(self.source, "d,0,1") # print "self.fn_prefix is",self.fn_prefix result = runrepl.edit_output(self.fn_prefix) # print "result is", pprint.pformat(result) except Exception, e: self.fail(str(e)) # Two edit commands try: self._writeAndFlush(self.source, "d,2,3;s,0,5,10") result = runrepl.edit_output(self.fn_prefix) # print "result is", pprint.pformat(result) except Exception, e: self.fail(str(e))