Skip to content

Commit 3fd4ee4

Browse files
mrcfpscmccandless
authored andcommitted
word-count: update tests to v1.2.0 (#1270)
* word-count: update tests to v1.2.0 * word-count: adjust the test cases to v1.2.0 * Fix typo in a method name (L22) * Correct test method name according to canonical data (L52) * Move multiple spaces test above track-specific tests * Remove `test_newlines` which duplicates `test_expanded_list`
1 parent cd00460 commit 3fd4ee4

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

exercises/word-count/word_count_test.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from word_count import word_count
44

55

6+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
7+
68
class WordCountTests(unittest.TestCase):
79

810
def test_count_one_word(self):
@@ -17,7 +19,7 @@ def test_count_one_of_each(self):
1719
{'one': 1, 'of': 1, 'each': 1}
1820
)
1921

20-
def test_count_multiple_occurences(self):
22+
def test_count_multiple_occurrences_of_a_word(self):
2123
self.assertEqual(
2224
word_count('one fish two fish red fish blue fish'),
2325
{'one': 1, 'fish': 4, 'two': 1, 'red': 1, 'blue': 1}
@@ -47,7 +49,7 @@ def test_include_numbers(self):
4749
{'testing': 2, '1': 1, '2': 1}
4850
)
4951

50-
def test_mixed_case(self):
52+
def test_normalize_case(self):
5153
self.assertEqual(
5254
word_count('go Go GO Stop stop'),
5355
{'go': 3, 'stop': 2}
@@ -66,21 +68,13 @@ def test_quotations(self):
6668
'and': 1}
6769
)
6870

69-
# Additional tests for this track
70-
71-
def test_multiple_spaces(self):
71+
def test_multiple_spaces_not_detected_as_a_word(self):
7272
self.assertEqual(
73-
word_count('wait for it'),
74-
{'wait': 1, 'for': 1, 'it': 1}
73+
word_count(' multiple whitespaces'),
74+
{'multiple': 1, 'whitespaces': 1}
7575
)
7676

77-
def test_newlines(self):
78-
self.assertEqual(
79-
word_count('rah rah ah ah ah\nroma roma ma\n'
80-
'ga ga oh la la\nwant your bad romance'),
81-
{'rah': 2, 'ah': 3, 'roma': 2, 'ma': 1, 'ga': 2, 'oh': 1, 'la': 2,
82-
'want': 1, 'your': 1, 'bad': 1, 'romance': 1}
83-
)
77+
# Additional tests for this track
8478

8579
def test_tabs(self):
8680
self.assertEqual(

0 commit comments

Comments
 (0)