root/pyndexter/trunk/pyndexter/tests/util.py

Revision 452, 0.9 kB (checked in by athomas, 1 year ago)

pyndexter: All modules are now prefixed with _ to avoid import collisions. Updated unit tests.

  • Property svn:eol-style set to native
Line 
1 import unittest
2 from pyndexter import *
3 from pyndexter.util import excerpt
4 from pyndexter.tests.corpus import documents, corpus
5
6 class ExcerptTestCase(unittest.TestCase):
7     def test_excerpt(self):
8         terms = Query('lorem ipsum').terms()
9         text = excerpt(documents['mock://3'].content, terms)
10         self.assertEquals(unicode(text), u"""...  Etiam pharetra. Vivamus """
11             """diam ipsum, luctus et, luctus nec, auctor vel,\ntellus. """
12             """Vestibulum lobortis feugiat dolor. Phasellus diam felis, """
13             """commodo vitae,\nlaoreet ac, euismod sit amet, nunc. """
14             """Vestibulum ut metus. Praesent vel nibh ac\nlibero """
15             """convallis imperdiet. Morbi dignis ...""")
16
17 def suite():
18     suite = unittest.TestSuite()
19     suite.addTest(unittest.makeSuite(ExcerptTestCase, 'test'))
20     return suite
21
22
23 if __name__ == '__main__':
24     unittest.main(defaultTest='suite')
Note: See TracBrowser for help on using the browser.