Skip to content

Commit

Permalink
word-count: Remove unicode test case
Browse files Browse the repository at this point in the history
  • Loading branch information
behrtam committed Mar 8, 2017
1 parent c944dac commit 1bfda09
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
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()

0 comments on commit 1bfda09

Please sign in to comment.