class WordCounterFixtureTests(TestCase): def setUp(self): """Prepare before each test""" MOBYDICK_SUMMARY = open('mobydick_summary.txt').read() self.text = TextBody(MOBYDICK_SUMMARY) self.counter = WordCounter(self.text) def test_count_months(self): self.assertEqual(self.counter.count_word("months"), 1) def test_count_the(self): """Count word in a longer text""" self.assertEqual(self.counter.count_word("the"), 6) def tearDown(self): """Clean up after a test has passed or failed.""" pass
def test_count_word_complex(): """Count word in a longer text""" text = TextBody(MOBYDICK_SUMMARY) counter = WordCounter(text) assert_equal(counter.count_word("white"), 2)
def test_count_word_simple(): """Count word in a short text""" text = TextBody("the white white whale") counter = WordCounter(text) assert_equal(counter.count_word("white"), 2)
def test_count_word_simple(self): """Count a single word""" counter = WordCounter(MockText) self.assertEqual(counter.count_word("white"), 2)