Ejemplo n.º 1
0
def main(filename):
    text = open(filename).read()
    count_stat = count_word(text)
    for word, count in count_stat:
        print(word, count)
def test_tempty():
    test_case = ""
    answer = word_count.count_word(test_case)
    assert answer == 0
def test_single():
    test_case = "a"
    answer = word_count.count_word(test_case)
    assert answer == 1
Ejemplo n.º 4
0
 def test_empty(self):
     test_val = ""
     self.assertEqual(word_count.count_word(test_val), 0)
def test_even_p():
    test_case = "This is an activity"
    answer = word_count.count_word(test_case)
    assert answer == 3  #fail test should be 4
Ejemplo n.º 6
0
 def test_sentence(self):
     test_val = "This is an activity"
     self.assertEqual(word_count.count_word(test_val),
                      3)  #fail test should be 4
Ejemplo n.º 7
0
 def test_char(self):
     test_val = "a"
     self.assertEqual(word_count.count_word(test_val), 1)
 def test2(self):
     res = count_word("Kevin")
     self.assertEqual(res, 1)
 def test1(self):
     res = count_word("")
     self.assertEqual(res, 0)
 def test3(self):
     res = count_word("How are you?")
     self.assertEqual(res, 3)