-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_count_lines.py
42 lines (34 loc) · 1.38 KB
/
test_count_lines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import unittest
from poetry_functions import count_lines
class Test_count_lines(unittest.TestCase):
def test_01_all_blank_empty_string(self):
''' Tests a list with only blanks and empty strings
'''
L = [' \n', '\n', ' \n\n']
expected = 0
self.assertEqual(count_lines(L), expected, "count_lines([' ', '\n', ''])")
def test_02_empty_list(self):
'''Tests an empty list
'''
L = []
expected = 0
self.assertEqual(count_lines(L), expected, "count_lines([])")
def test_03_multiple_words_with_empty_and_newline_strings(self):
''' Tests mixed strings with blank strings and newline character
'''
L = ['text\n', '', 'more text\n', '\n']
expected = 2
self.assertEqual(count_lines(L), expected, "count_lines(['text\n', '', 'more text\n', '\n'])")
def test_04_one_string_list(self):
''' Tests only one string in a list
'''
L = ['text\n']
expected = 1
self.assertEqual(count_lines(L), expected, "count_lines(['text\n'])")
def test_05_multiple_string_list(self):
''' Tests multiple strings in a list
'''
L = ['text\n', 'coding\n', 'is\n', 'awesome\n']
expected = 4
self.assertEqual(count_lines(L), expected, "count_lines(['text\n', 'coding\n', 'is\n', 'awesome\n'])")
unittest.main(exit=False)