示例#1
0
 def test(self):
     wrapper = ParagraphWrapper(width=5)
     self.assertEqual(
         wrapper.wrap('12\n'
                      '34\n'
                      '56\n'
                      '78\n'
                      '90\n'
                      '\n'
                      '1234567890'),
         ['12 34',
          '56 78',
          '90',
          '',
          '12345',
          '67890']
     )
示例#2
0
 def test(self):
     wrapper = ParagraphWrapper(width=5)
     self.assertEqual(
         wrapper.fill('12\n'
                      '34\n'
                      '56\n'
                      '78\n'
                      '90\n'
                      '\n'
                      '1234567890'),
         '12 34\n'
         '56 78\n'
         '90\n'
         '\n'
         '12345\n'
         '67890'
     )
示例#3
0
 def test_empty(self):
     self.assertEqual(ParagraphWrapper.split(''), [''])
     self.assertEqual(ParagraphWrapper.split('\n'), [''])
     self.assertEqual(ParagraphWrapper.split('\n\n'), [''])
     self.assertEqual(ParagraphWrapper.split('\n\n\n'), [''])
     self.assertEqual(ParagraphWrapper.split('\n\n\n\n'), [''])
     self.assertEqual(ParagraphWrapper.split('\n\n \n\n'), [''])
示例#4
0
 def test_trailing_whitespace(self):
     self.assertEqual(ParagraphWrapper.split(' '), [' '])
     self.assertEqual(ParagraphWrapper.split(' \n'), [' '])
     self.assertEqual(ParagraphWrapper.split(' \n\n'), [' ', ''])
     self.assertEqual(ParagraphWrapper.split(' \n\n\n\n'), [' ', ''])
     self.assertEqual(ParagraphWrapper.split(' \n\n \n\n'), [' ', ''])