Skip to content

Commit 217104e

Browse files
authored
word-count: Remove unicode test case (#427)
As discussed in exercism/problem-specifications#441 Fixes #416
1 parent 17debf9 commit 217104e

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

exercises/word-count/example.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
from collections import Counter
22

33

4-
# to be backwards compatible with the old Python 2.X
5-
def decode_if_needed(string):
6-
try:
7-
return string.decode('utf-8')
8-
except AttributeError:
9-
return string
10-
11-
124
def word_count(text):
135
def replace_nonalpha(char):
146
return char.lower() if char.isalnum() else ' '
15-
text = ''.join(replace_nonalpha(c) for c in decode_if_needed(text))
7+
text = ''.join(replace_nonalpha(c) for c in text)
168
return Counter(text.split())

exercises/word-count/word_count_test.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
# -*- coding: utf-8 -*-
21
import unittest
32

43
from word_count import word_count
54

65

7-
# to be backwards compatible with the old Python 2.X
8-
def decode_if_needed(string):
9-
try:
10-
return string.decode('utf-8')
11-
except AttributeError:
12-
return string
13-
14-
156
class WordCountTests(unittest.TestCase):
167

178
def test_count_one_word(self):
@@ -78,12 +69,6 @@ def test_non_alphanumeric(self):
7869
word_count('hey,my_spacebar_is_broken.')
7970
)
8071

81-
def test_unicode(self):
82-
self.assertEqual(
83-
{decode_if_needed('до'): 1, decode_if_needed('свидания'): 1},
84-
word_count('до🖖свидания!')
85-
)
86-
8772

8873
if __name__ == '__main__':
8974
unittest.main()

0 commit comments

Comments
 (0)