Skip to content

word-count: Remove unicode test case #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions exercises/word-count/example.py
Original file line number Diff line number Diff line change
@@ -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())
15 changes: 0 additions & 15 deletions exercises/word-count/word_count_test.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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()