test.py 430 B

12345678910111213141516
  1. import unittest
  2. import truncate
  3. class TestTruncate(unittest.TestCase):
  4. def testLimit(self):
  5. self.assertEqual(truncate('heqingyang', 5) , 'heqin...')
  6. self.assertEqual(truncate('heqingyang', 20) , 'heqingyang')
  7. def testEllipsis(self):
  8. self.assertEqual(truncate('heqingyang', 5) , 'heqin...')
  9. self.assertEqual(truncate('heqingyang', 5, ellipsis=' more') , 'heqin more')
  10. if __name__ == '__main__':
  11. unittest.main()