-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_count_lines.py
82 lines (53 loc) · 2.29 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import unittest
from poetry_functions import count_lines
class Test_count_lines(unittest.TestCase):
def test_empty_list(self):
"""
Test the empty list.
"""
self.assertEqual(count_lines([]),0,
'empty list')
def test_list_of_non_empty_non_blank_string(self):
"""
Test the list of non-blank, non-empty strings.
"""
self.assertEqual(count_lines(['dada ']), 1,
'list of one non-blank, non-empty string')
self.assertEqual(count_lines(['dada ', 'daa']), 2,
'list of multiple non-blank, non-empty lines')
def test_list_of_blank_string(self):
"""
Test the list of blank strings.
"""
self.assertEqual(count_lines([' ']), 0,
'only one blank tring')
self.assertEqual(count_lines([' ', ' ']), 0,
'multiple_blank strings')
def test_list_of_empty_string(self):
"""
Test the list of empty strings.
"""
self.assertEqual(count_lines(['']), 0,
'only one empty string')
self.assertEqual(count_lines(['', '']), 0,
'multiple empty strings')
def test_list_of_mutiple_types_of_lines(self):
"""
Test the list of strings with empty string,blank string and non-empty,
non-blank string.
"""
self.assertEqual(count_lines(['', 'dad', ' ', ' dsadf']), 2,
'list of srings with empty string,blank string and non-empty,' + \
'non-blank string')
def test_list_of_strings_with_character_of_new_line(self):
"""
Test the list of strings with characters.
"""
self.assertEqual(count_lines(['faff\n', '\n', ' \n']), 1,
'list of strings with character of new line in the end')
self.assertEqual(count_lines(['fa\nf', ' \n ']), 1,
'list of strings with character of new line in the middle')
self.assertEqual(count_lines(['da\n\n', '\n \n ', '\n \n']), 1,
'list of strings with characters of new line in the end or in' + \
'the middle')
unittest.main(exit=False)