コード例 #1
0
 def testTruncate_LongFill(self):
     self.assertEqual(
         exceptions._TruncateToLineWidth(self.string,
                                         self.middle_idx,
                                         self.width,
                                         fill='.' * int(self.width / 2)),
         self.string)
コード例 #2
0
 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')
コード例 #3
0
 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...')
コード例 #4
0
 def testTruncate_AlignMiddleFill(self):
     self.assertEqual(
         exceptions._TruncateToLineWidth(self.string,
                                         self.middle_idx,
                                         self.width,
                                         fill='...'), '...5678...')
コード例 #5
0
 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')
コード例 #6
0
 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')
コード例 #7
0
 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')
コード例 #8
0
 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')