def testTruncate_LongFill(self): self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.middle_idx, self.width, fill='.' * int(self.width / 2)), self.string)
def testTruncate_AlignEndFill(self): """Test that string aligned to the end has its beginning filled in.""" self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.end_idx, self.width, fill='...'), '...9abcdef')
def testTruncate_AlignBeginningFill(self): """Test that string aligned to the beginning has its end filled in.""" self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.beginning_idx, self.width, fill='...'), '0123456...')
def testTruncate_AlignMiddleFill(self): self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.middle_idx, self.width, fill='...'), '...5678...')
def testTruncate_AlignMiddle(self): """Test that a string aligned to the end has its beginning truncated.""" self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.middle_idx, self.width), '23456789ab')
def testTruncate_AlignEnd(self): """Test that a string aligned to the end has its beginning truncated.""" self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.end_idx, self.width), '6789abcdef')
def testTruncate_AlignBeginning(self): """Test that a string aligned to the beginning has its end truncated.""" self.assertEqual( exceptions._TruncateToLineWidth(self.string, self.beginning_idx, self.width), '0123456789')
def testTruncate_NoTruncationNeeded(self): """Test that a string shorter than the terminal width is not truncated.""" self.assertEqual(exceptions._TruncateToLineWidth('foo', 0, self.width), 'foo')