def test_033(self): """ Page store/load - unicode - latin """ page = Page(text="hāllo world, goodbye") page.store('files/tmp.txt') page._words = None page.load('files/tmp.txt') self.assertEqual(towords(page.words), ["hāllo", "world", "goodbye"]) os.remove("files/tmp.txt") Page.ROMAN = True page = Page(text="québec") page.store('files/tmp.txt') page._words = None page.load('files/tmp.txt') Page.ROMAN = False self.assertEqual(towords(page.words), ["quebec"]) os.remove("files/tmp.txt")
def test_026(self): """ Page overridden += : words is non-None """ page = Page(text="hello") self.assertEqual(len(page), 1) page += "world" self.assertEqual(page.text, "hello world") self.assertEqual(len(page), 2)
def test_032(self): """ Page store/load """ page = Page(text="hello world, goodbye") page.store('files/tmp.txt') page._words = None page.load('files/tmp.txt') os.remove("files/tmp.txt") self.assertEqual(towords(page.words), ["hello", "world", "goodbye"])
def test_034(self): """ Page - Bag of Words """ page = Page(text="zoo castle zoo bird zoo bird") self.assertEqual(page.bagOfWords, {'zoo': 3, 'castle': 1, 'bird': 2})
def test_001(self): """ Page constructor - no parameters """ page = Page() self.assertEqual(page.path, None) self.assertEqual(page.text, None) self.assertEqual(page.words, None)
def test_031(self): """ Page number """ page = Page("files/test.txt") self.assertEqual(page.pageno, None) page = Page("files/test.txt", pageno=2) self.assertEqual(page.pageno, 2)