forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Delete solutions/tests/test_word_frequency.py"
This reverts commit 8512058.
- Loading branch information
1 parent
124de56
commit 21ffdbb
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# test_word_frequency.py | ||
""" | ||
This module contains unit tests for the word_frequency module. | ||
The tests verify the functionality of the count_word_frequency function, | ||
which counts the frequency of words in a given text. | ||
""" | ||
|
||
import unittest | ||
|
||
from ..word_frequency import count_word_frequency | ||
|
||
|
||
class TestWordFrequency(unittest.TestCase): | ||
"""Test cases for the count_word_frequency function.""" | ||
|
||
def test_count_word_frequency(self): | ||
"""Test counting word frequency in a simple text.""" | ||
text = "hello world hello" | ||
expected_output = {"hello": 2, "world": 1} | ||
self.assertEqual(count_word_frequency(text), expected_output) | ||
|
||
def test_empty_text(self): | ||
"""Test counting word frequency in an empty string.""" | ||
text = "" | ||
expected_output = {} | ||
self.assertEqual(count_word_frequency(text), expected_output) | ||
|
||
def test_case_insensitive(self): | ||
"""Test counting word frequency with case-insensitive matching.""" | ||
text = "Hello hello HeLLo" | ||
expected_output = {"hello": 3} | ||
self.assertEqual(count_word_frequency(text), expected_output) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |