diff --git a/e2e_toy/tests/test_textops.py b/e2e_toy/tests/test_textops.py index e05680d..f4c21cf 100644 --- a/e2e_toy/tests/test_textops.py +++ b/e2e_toy/tests/test_textops.py @@ -7,6 +7,10 @@ class WordCountTest(unittest.TestCase): def test_single_spaces(self): self.assertEqual(word_count("a b c"), 3) + def test_repeated_spaces(self): + self.assertEqual(word_count("hello world"), 2) + self.assertEqual(word_count(" padded\ttext\n"), 2) + class SlugifyTest(unittest.TestCase): def test_basic(self): diff --git a/e2e_toy/textops.py b/e2e_toy/textops.py index 8f71f6c..359ef78 100644 --- a/e2e_toy/textops.py +++ b/e2e_toy/textops.py @@ -6,7 +6,7 @@ def word_count(text): """Number of whitespace-separated words in ``text``.""" - return len(text.split(" ")) + return len(text.split()) def slugify(text):