def test_no_input(monkeypatch):
    monkeypatch.setattr('sys.stdin', noInput)
    assert wordCount.wordCounter() == 0
def test_special2(monkeypatch):
    monkeypatch.setattr('sys.stdin', specialCharInput2)
    assert wordCount.wordCounter() == 4
def test_one_word(monkeypatch):
    monkeypatch.setattr('sys.stdin', oneWordInput)
    assert wordCount.wordCounter() == 1
def test_string_of_numbers(monkeypatch):
    monkeypatch.setattr('sys.stdin', numberInput)
    assert wordCount.wordCounter() == 10
def test_many_spaces(monkeypatch):
    monkeypatch.setattr('sys.stdin', multipleSpaces)
    assert wordCount.wordCounter() == 9
示例#6
0
 def test_add(self):
     self.assertEqual(wordCount.wordCounter("This is 4 words."), 4)
     self.assertEqual(wordCount.wordCounter("A few more cool words."), 5)
示例#7
0
 def test_add_numbers(self):
     self.assertEqual(wordCount.wordCounter("1 2 3 4 5 6 7 8"), 8)
示例#8
0
 def test_no_words(self, mock_input):
     result = wordCount.wordCounter()
     self.assertEqual(result, 0)
示例#9
0
 def test_add_spaces(self):
     self.assertEqual(wordCount.wordCounter(" This is incorrect"), 3)
示例#10
0
 def test_special_chars_complex(self, mock_input):
     result = wordCount.wordCounter()
     self.assertEqual(result, 5)
示例#11
0
 def test_one_word(self, mock_input):
     result = wordCount.wordCounter()
     self.assertEqual(result, 1)
示例#12
0
 def test_string_with_multiple_spaces(self, mock_input):
     result = wordCount.wordCounter()
     self.assertEqual(result, 10)
示例#13
0
 def test_string_of_ints(self, mock_input):
     result = wordCount.wordCounter()
     self.assertEqual(result, 10)
示例#14
0
def test_numbers():
    assert wordCount.wordCounter("1 2 3 4 5 6 7 8") == 8
示例#15
0
def test_answer():
    assert wordCount.wordCounter("This is 4 words.") == 4
    assert wordCount.wordCounter("A few more cool words.") == 5
示例#16
0
def test_spaces():
    assert wordCount.wordCounter(" This is incorrect") == 3