def test_shortener_non_nice_custom_suffix(self): s = 'loremipsumdolorsitamet' length = 12 suffix = 'the_suffix' self.assertEqual( shorten('loremipsumdolorsitamet', length=length, suffix=suffix), '%s%s' % (s[:12], suffix))
def test_7(self): test = strings.shorten("sadasdasd dsadsadas asdasdasd asdasdasdas",15, token="-", keep=True) self.assertGreaterEqual(15, len(test))
def test_6(self): test = strings.shorten("sadasdasd dsadsadas asdasdasd asdasdasdas",15, token="-") self.assertEqual(15, len(test))
def test_5(self): test = strings.shorten("sadasdasd dsadsadas asdasdasd asdasdasdas",15) self.assertEqual(15, len(test))
def test_4(self): test = strings.shorten("Test 4",10) self.assertEqual(6, len(test))
def test_3(self): test = strings.shorten("Test 3",6) self.assertEqual(6, len(test))
def test_2(self): test = strings.shorten("Test 2",5) self.assertEqual(5, len(test))
def test_1(self): test = strings.shorten("",5) self.assertEqual("", test)
def test_shortener_non_nice_no_shortening_expected(self): s = 'lorem ipsum dolor sit amet' length = 100 self.assertEqual(shorten(s, length=length, nice=False), s)
def test_shortener_nice_unsplittable_string(self): s = 'loremipsumdolorsitamet' length = 12 self.assertEqual(shorten(s, length=length, nice=True), '%s...' % s[:length])
def test_shortener_nice_zero_length(self): s = 'lorem ipsum dolor sit amet' length = 0 self.assertEqual(shorten(s, length=length, nice=True), '...')
def test_shortener_nice(self): s = 'lorem ipsum dolor sit amet' length = 14 self.assertEqual(shorten(s, length=length, nice=True), 'lorem ipsum...')
def test_shortener_non_nice(self): s = 'loremipsumdolorsitamet' length = 12 self.assertEqual(shorten('loremipsumdolorsitamet', length=length), '%s...' % s[:12])