Beispiel #1
0
 def test_excerpt(self):
     self.assertEqual("...lo my wo...",
                      excerpt("hello my world", "my", 3))
     self.assertEqual("...is a beautiful morn...",
                      excerpt("This is a beautiful morning", "beautiful", 5))
     self.assertEqual("This is a...",
                      excerpt("This is a beautiful morning", "this", 5))
     self.assertEqual("...iful morning",
                      excerpt("This is a beautiful morning", "morning", 5))
     self.assertEqual('',
                      excerpt("This is a beautiful morning", "day"))
Beispiel #2
0
 def test_excerpt_with_utf8(self):
     self.assertEqual(u"...fficiency could not be ...",
                      excerpt(u"That's why efficiency could not be helped", 'could', 8))
Beispiel #3
0
 def test_excerpt_with_regex(self):
     self.assertEqual('...is a beautiful! mor...',
                      excerpt('This is a beautiful! morning', 'beautiful', 5))
     self.assertEqual('...is a beautiful? mor...',
                      excerpt('This is a beautiful? morning', 'beautiful', 5))