Exemplo n.º 1
0
 def assertIndexToRange(self, text, index, expected_range):
     citer = Citer()
     actual = citer.indexToRange(text, index)
     self.assertEqual(expected_range, actual,
         "Expected index {index} to be range"
         " {expected_range} but it was actually {actual}"
         "\n\n{text!r}".format(**locals()))        
Exemplo n.º 2
0
 def assertRangeToIndex(self, text, trange, expected_index):
     citer = Citer()
     actual = citer.rangeToIndex(text, trange)
     self.assertEqual(expected_index, actual,
         "Expected range {trange} to be index"
         " {expected_index} but it was actually {actual}"
         "\n\n{text!r}".format(**locals()))
Exemplo n.º 3
0
 def assertIndex(self, text, point, expected_index):
     """
     Assert that the given point resolves to the expected_index.
     """
     citer = Citer()
     actual = citer.pointToIndex(text, point)
     self.assertEqual(actual, expected_index,
         u"Expected point {point} to"
         u" be converted to index {expected_index} but it was {actual}"
         u"\n\n{text!r}".format(**locals()).encode('utf-8'))
Exemplo n.º 4
0
    def assertPoint(self, text, index, point, reverse=True):
        """
        Assert that the given index within the given text produces the
        expected point
        """
        citer = Citer()
        actual = citer.indexToPoint(text, index)
        self.assertEqual(point, unicode(actual),
            u"Expected index {index} to"
            u" be at point {point} but it was {actual}"
            u"\n\n{text!r}".format(**locals()).encode('utf-8'))

        if reverse:
            # assert the reverse
            self.assertIndex(text, point, index)