Skip to content

Commit

Permalink
Reorganized and added tests for split_keep_whitespace()
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaGrace committed Jul 19, 2017
1 parent ea9dcbe commit 8f7849e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/unit_test/test_cut_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
count_words, cut_by_number


class TestCutByNumbers:
class TestNumberCutHelpers:
def test_split_keep_whitespace(self):
assert split_keep_whitespace("Test string") == ["Test", " ", "string"]
assert split_keep_whitespace("Test") == ["Test"]
assert split_keep_whitespace("Test ") == ["Test", " ", ""] # intended?
assert split_keep_whitespace(" ") == ["", " ", ""] # intended?
assert split_keep_whitespace("") == [""]

Expand All @@ -14,10 +15,15 @@ def test_count_words(self):
assert count_words(['\n', '\t', ' ', '', '\u3000', "word"]) == 1
assert count_words([""]) == 0


class TestCutByNumbers:
def test_cut_by_number_normal(self):
assert cut_by_number("Text", 1) == ["Text"]
assert cut_by_number("This text has five words", 5) == \
["This ", "text ", "has ", "five ", "words"]
assert len(cut_by_number("Odd number of words in this text", 6)) == 6
assert len(cut_by_number("Almost enough words here but not quite", 4))\
== 4

def test_cut_by_number_spacing(self):
assert cut_by_number("Hanging space ", 2) == ["Hanging ", "space "]
Expand Down

0 comments on commit 8f7849e

Please sign in to comment.