예제 #1
0
class Processing(unittest.TestCase):
    def setUp(self):
        self.f = TextReader(PREFIX + "/LICENSE.txt",linesep=TextReader.UNIX)

    def testStrip(self):
        self.f.autostrip = True
        self.assertEqual(self.f.peekline(28),
                          'Release         Derived     Year        Owner       GPL-')
        self.f.autostrip = False
        self.assertEqual(self.f.peekline(28),
                          '    Release         Derived     Year        Owner       GPL-')
        self.f.seek(0)

    def testDewrap(self):
        self.f.autodewrap = True
        self.assertEqual(self.f.readparagraph(),
                          'A. HISTORY OF THE SOFTWARE ==========================')
        self.f.seek(0)
        self.f.autodewrap = False
        self.assertEqual(self.f.readparagraph(),
                          'A. HISTORY OF THE SOFTWARE'+self.f.linesep+'==========================')
        self.f.seek(0)
        

    def testDehyphenate(self):
        pass

    def testExpandtabs(self):
        pass

    def testReadTable(self):
        # Should this even be in the Processing test suite?
        pass
예제 #2
0
class Processing(unittest.TestCase):
    def setUp(self):
        self.f = TextReader(PREFIX + "/LICENSE.txt", linesep=TextReader.UNIX)

    def testStrip(self):
        self.f.autostrip = True
        self.assertEqual(
            self.f.peekline(28),
            'Release         Derived     Year        Owner       GPL-')
        self.f.autostrip = False
        self.assertEqual(
            self.f.peekline(28),
            '    Release         Derived     Year        Owner       GPL-')
        self.f.seek(0)

    def testDewrap(self):
        self.f.autodewrap = True
        self.assertEqual(
            self.f.readparagraph(),
            'A. HISTORY OF THE SOFTWARE ==========================')
        self.f.seek(0)
        self.f.autodewrap = False
        self.assertEqual(
            self.f.readparagraph(), 'A. HISTORY OF THE SOFTWARE' +
            self.f.linesep + '==========================')
        self.f.seek(0)

    def testDehyphenate(self):
        pass

    def testExpandtabs(self):
        pass

    def testReadTable(self):
        # Should this even be in the Processing test suite?
        pass
예제 #3
0
class Basic(unittest.TestCase):
    def setUp(self):
        self.f = TextReader(PREFIX + "/LICENSE.txt", linesep=TextReader.UNIX)

    def testReadline(self):
        self.assertEqual(self.f.readline(),
                         'A. HISTORY OF THE SOFTWARE')

        self.assertEqual(self.f.readline(),
                         '==========================')
        self.f.seek(0)

    def testIterateFile(self):
        self.assertEqual(self.f.bof(), True)
        self.assertEqual(self.f.eof(), False)
        for line in self.f:
            pass
        self.assertEqual(self.f.bof(), False)
        self.assertEqual(self.f.eof(), True)
        self.f.seek(0)
        
    def testReadparagraph(self):
        l = self.f.readparagraph()
        self.assertEqual(l, 'A. HISTORY OF THE SOFTWARE'+self.f.linesep+'==========================')
        l = self.f.readparagraph()
        self.assertEqual(l, 'Python was created in the early 1990s by Guido van Rossum at Stichting'+self.f.linesep+
                         'Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands'+self.f.linesep+
                         'as a successor of a language called ABC.  Guido remains Python\'s'+self.f.linesep+
                         'principal author, although it includes many contributions from others.')
        self.f.cuepast("to make these releases possible.") # next paragraph is separated by three newlines
        t = self.f.readparagraph()[:23]
        self.assertEqual(t,"B. TERMS AND CONDITIONS")
        self.f.seek(0)

    def testReadChunk(self):
        l = self.f.readchunk('(')
        l = self.f.readchunk(')')
        self.assertEqual(l,'CWI, see http://www.cwi.nl')
        self.f.seek(0)

    def testPeekLine(self):
        l = self.f.peekline()
        self.assertEqual(l, 'A. HISTORY OF THE SOFTWARE')
        l = self.f.peekline(4)
        self.assertEqual(l, 'Python was created in the early 1990s by Guido van Rossum at Stichting')
        self.f.seek(0)
        
    def testPeekParagraph(self):
        l = self.f.peekparagraph()
        self.assertEqual(l, 'A. HISTORY OF THE SOFTWARE'+self.f.linesep+'==========================')
        l = self.f.peekparagraph(2)
        self.assertEqual(l, 'Python was created in the early 1990s by Guido van Rossum at Stichting'+self.f.linesep+
                         'Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands'+self.f.linesep+
                         'as a successor of a language called ABC.  Guido remains Python\'s'+self.f.linesep+
                         'principal author, although it includes many contributions from others.')
        self.f.seek(0)

    

    def testPrevLine(self):
        self.f.readparagraph()
        self.f.readparagraph()
        self.assertEqual(self.f.prevline(3), # first two newlines, then the actual previous line (does this make sense?)
                         'principal author, although it includes many contributions from others.')
        self.assertEqual(self.f.prevline(6),
                         'Python was created in the early 1990s by Guido van Rossum at Stichting')
        self.f.seek(0)

    def testCue(self):
        self.f.cue("Guido")
        self.assertEqual(self.f.readline(),
                          'Guido van Rossum at Stichting')
        self.f.seek(0)

    def testCuePast(self):
        self.f.cuepast("Guido")
        self.assertEqual(self.f.readline(),
                          ' van Rossum at Stichting')
        self.f.seek(0)

    def testReadTo(self):
        self.assertEqual(self.f.readto("SOFTWARE"),
                          'A. HISTORY OF THE ')
예제 #4
0
class Basic(unittest.TestCase):
    def setUp(self):
        self.f = TextReader(PREFIX + "/LICENSE.txt", linesep=TextReader.UNIX)

    def testReadline(self):
        self.assertEqual(self.f.readline(), 'A. HISTORY OF THE SOFTWARE')

        self.assertEqual(self.f.readline(), '==========================')
        self.f.seek(0)

    def testIterateFile(self):
        self.assertEqual(self.f.bof(), True)
        self.assertEqual(self.f.eof(), False)
        for line in self.f:
            pass
        self.assertEqual(self.f.bof(), False)
        self.assertEqual(self.f.eof(), True)
        self.f.seek(0)

    def testReadparagraph(self):
        l = self.f.readparagraph()
        self.assertEqual(
            l, 'A. HISTORY OF THE SOFTWARE' + self.f.linesep +
            '==========================')
        l = self.f.readparagraph()
        self.assertEqual(
            l,
            'Python was created in the early 1990s by Guido van Rossum at Stichting'
            + self.f.linesep +
            'Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands'
            + self.f.linesep +
            'as a successor of a language called ABC.  Guido remains Python\'s'
            + self.f.linesep +
            'principal author, although it includes many contributions from others.'
        )
        self.f.cuepast("to make these releases possible."
                       )  # next paragraph is separated by three newlines
        t = self.f.readparagraph()[:23]
        self.assertEqual(t, "B. TERMS AND CONDITIONS")
        self.f.seek(0)

    def testReadChunk(self):
        l = self.f.readchunk('(')
        l = self.f.readchunk(')')
        self.assertEqual(l, 'CWI, see http://www.cwi.nl')
        self.f.seek(0)

    def testPeekLine(self):
        l = self.f.peekline()
        self.assertEqual(l, 'A. HISTORY OF THE SOFTWARE')
        l = self.f.peekline(4)
        self.assertEqual(
            l,
            'Python was created in the early 1990s by Guido van Rossum at Stichting'
        )
        self.f.seek(0)

    def testPeekParagraph(self):
        l = self.f.peekparagraph()
        self.assertEqual(
            l, 'A. HISTORY OF THE SOFTWARE' + self.f.linesep +
            '==========================')
        l = self.f.peekparagraph(2)
        self.assertEqual(
            l,
            'Python was created in the early 1990s by Guido van Rossum at Stichting'
            + self.f.linesep +
            'Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands'
            + self.f.linesep +
            'as a successor of a language called ABC.  Guido remains Python\'s'
            + self.f.linesep +
            'principal author, although it includes many contributions from others.'
        )
        self.f.seek(0)

    def testPrevLine(self):
        self.f.readparagraph()
        self.f.readparagraph()
        self.assertEqual(
            self.f.prevline(
                3
            ),  # first two newlines, then the actual previous line (does this make sense?)
            'principal author, although it includes many contributions from others.'
        )
        self.assertEqual(
            self.f.prevline(6),
            'Python was created in the early 1990s by Guido van Rossum at Stichting'
        )
        self.f.seek(0)

    def testCue(self):
        self.f.cue("Guido")
        self.assertEqual(self.f.readline(), 'Guido van Rossum at Stichting')
        self.f.seek(0)

    def testCuePast(self):
        self.f.cuepast("Guido")
        self.assertEqual(self.f.readline(), ' van Rossum at Stichting')
        self.f.seek(0)

    def testReadTo(self):
        self.assertEqual(self.f.readto("SOFTWARE"), 'A. HISTORY OF THE ')