diff --git a/exercises/word-count/example.py b/exercises/word-count/example.py index 2a4be582767..995a7d6ca83 100644 --- a/exercises/word-count/example.py +++ b/exercises/word-count/example.py @@ -1,16 +1,8 @@ from collections import Counter -# to be backwards compatible with the old Python 2.X -def decode_if_needed(string): - try: - return string.decode('utf-8') - except AttributeError: - return string - - def word_count(text): def replace_nonalpha(char): return char.lower() if char.isalnum() else ' ' - text = ''.join(replace_nonalpha(c) for c in decode_if_needed(text)) + text = ''.join(replace_nonalpha(c) for c in text) return Counter(text.split()) diff --git a/exercises/word-count/word_count_test.py b/exercises/word-count/word_count_test.py index 26298eb23cb..bb261e47133 100644 --- a/exercises/word-count/word_count_test.py +++ b/exercises/word-count/word_count_test.py @@ -1,17 +1,8 @@ -# -*- coding: utf-8 -*- import unittest from word_count import word_count -# to be backwards compatible with the old Python 2.X -def decode_if_needed(string): - try: - return string.decode('utf-8') - except AttributeError: - return string - - class WordCountTests(unittest.TestCase): def test_count_one_word(self): @@ -78,12 +69,6 @@ def test_non_alphanumeric(self): word_count('hey,my_spacebar_is_broken.') ) - def test_unicode(self): - self.assertEqual( - {decode_if_needed('до'): 1, decode_if_needed('свидания'): 1}, - word_count('до🖖свидания!') - ) - if __name__ == '__main__': unittest.main()