예제 #1
0
 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))
예제 #2
0
 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))
예제 #3
0
    def testCursorCmdStrip(self):
        """multiline cursor commands"""
        s = """sage: version()
'Sage Version 6.1.1, Release Date: 2014-02-04'
"""
        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))
예제 #4
0
    def testCursorCmdStrip(self):
        """multiline cursor commands"""
        s = """sage: version()
'Sage Version 6.1.1, Release Date: 2014-02-04'
"""
        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))
예제 #5
0
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))