def test_type(self): print( "If a there is an error from this test, the code is implemented correctly" ) with self.assertRaises(TypeError): wordCount.words() print("There is a Type Error ...")
def test_word_occurance0(self): self.assertDictEqual({ 'hello': 1, 'world': 1 }, words('hello world'), msg='should count multiple spaces as one')
def test_correctness(self): answer = len(wordCount.words()) expecteds = input( "How many words do you expect to be counted in the above sentence: " ) expected = int(expecteds) self.assertEqual(answer, expected)
def test_word_occurance8(self): self.assertDictEqual({ 'hello': 1, 'world': 1 }, words('hello\nworld'), msg='should not count multilines')
def test_word_occurance9(self): self.assertDictEqual({ 'hello': 1, 'world': 1 }, words('hello\tworld'), msg='should not count tabs')
def test_word_occurance6(self): self.assertDictEqual({ 'go': 1, 'Go': 1, 'GO': 1 }, words('go Go GO'), msg='should respect case')
def test_word_occurance5(self): self.assertDictEqual({ 'testing': 2, 1: 1, 2: 1 }, words('testing 1 2 testing'), msg='should include numbers')
def test_word_occurance2(self): self.assertDictEqual({ 'one': 1, 'of': 1, 'each': 1 }, words("one of each"), msg='should count one of each')
def test_word_occurance7(self): self.assertDictEqual( { "¡Hola!": 1, "¿Qué": 1, "tal?": 1, "??????!": 1 }, words('¡Hola! ¿Qué tal? ??????!'), msg='should count international characters properly')
def test_word_occurance3(self): self.assertDictEqual( { 'one': 1, 'fish': 4, 'two': 1, 'red': 1, 'blue': 1 }, words("one fish two fish red fish blue fish"), msg='should count multiple occurrences')
def test_word_occurance4(self): self.assertDictEqual( { 'car': 1, ":": 2, 'carpet': 1, 'as': 1, 'java': 1, 'javascript!!&@$%^&': 1 }, words('car : carpet as java : javascript!!&@$%^&'), msg='should include punctuation')
def test_negative(self): answer = len(wordCount.words()) self.assertLess(0, answer)
def test_word_occurance1(self): self.assertDictEqual({'word': 1}, words('word'), msg='should count one word')