@@ -10,37 +10,89 @@ class LittleSistersEssayTest(unittest.TestCase):
10
10
11
11
@pytest .mark .task (taskno = 1 )
12
12
def test_capitalize_word (self ):
13
- self .assertEqual (capitalize_title ("canopy" ), "Canopy" )
13
+
14
+ actual_result = capitalize_title ("canopy" )
15
+ expected = "Canopy"
16
+ error_message = (f'Called capitalize_title("canopy"). '
17
+ f'The function returned "{ actual_result } ", '
18
+ f'but the tests expected "{ expected } " for the title.' )
19
+
20
+ self .assertEqual (actual_result , expected , msg = error_message )
14
21
15
22
@pytest .mark .task (taskno = 1 )
16
23
def test_capitalize_title (self ):
17
- self .assertEqual (capitalize_title ("fish are cold blooded" ),
18
- "Fish Are Cold Blooded" )
24
+
25
+ actual_result = capitalize_title ("fish are cold blooded" )
26
+ expected = "Fish Are Cold Blooded"
27
+ error_message = (f'Called capitalize_title("fish are cold blooded"). '
28
+ f'The function returned "{ actual_result } ", '
29
+ f'but the tests expected "{ expected } " for the title.' )
30
+
31
+ self .assertEqual (actual_result , expected , msg = error_message )
19
32
20
33
@pytest .mark .task (taskno = 2 )
21
34
def test_sentence_ending (self ):
22
- self .assertEqual (check_sentence_ending ("Snails can sleep for 3 years." ), True )
35
+
36
+ actual_result = check_sentence_ending ("Snails can sleep for 3 years." )
37
+ expected = True
38
+ error_message = (f'Called check_sentence_ending("Snails can sleep for 3 years."). '
39
+ f'The function returned { actual_result } , '
40
+ f'but the tests expected { expected } for a period ending.' )
41
+
42
+ self .assertEqual (actual_result , expected , msg = error_message )
23
43
24
44
@pytest .mark .task (taskno = 2 )
25
45
def test_sentence_ending_without_period (self ):
26
- self .assertEqual (check_sentence_ending ("Fittonia are nice" ), False )
46
+
47
+ actual_result = check_sentence_ending ("Fittonia are nice" )
48
+ expected = False
49
+ error_message = (f'Called check_sentence_ending("Fittonia are nice"). '
50
+ f'The function returned { actual_result } , '
51
+ f'but the tests expected { expected } for a period ending.' )
52
+
53
+ self .assertEqual (actual_result , expected , msg = error_message )
27
54
28
55
@pytest .mark .task (taskno = 3 )
29
56
def test_remove_extra_spaces_only_start (self ):
30
- self .assertEqual (clean_up_spacing (" A rolling stone gathers no moss" ),
31
- "A rolling stone gathers no moss" )
57
+
58
+ actual_result = clean_up_spacing (" A rolling stone gathers no moss" )
59
+ expected = "A rolling stone gathers no moss"
60
+ error_message = (f'Called clean_up_spacing(" A rolling stone gathers no moss"). '
61
+ f'The function returned "{ actual_result } ", '
62
+ f'but the tests expected "{ expected } " as a cleaned string.' )
63
+
64
+ self .assertEqual (actual_result , expected , msg = error_message )
32
65
33
66
@pytest .mark .task (taskno = 3 )
34
67
def test_remove_extra_spaces (self ):
35
- self .assertEqual (clean_up_spacing (" Elephants can't jump. " ),
36
- "Elephants can't jump." )
68
+
69
+ actual_result = clean_up_spacing (" Elephants can't jump. " )
70
+ expected = "Elephants can't jump."
71
+ error_message = ("Called clean_up_spacing(\" Elephants can't jump. \" )"
72
+ f'The function returned "{ actual_result } ", '
73
+ f'but the tests expected "{ expected } " as a cleaned string.' )
74
+
75
+ self .assertEqual (actual_result , expected , msg = error_message )
37
76
38
77
@pytest .mark .task (taskno = 4 )
39
78
def test_replace_word_choice (self ):
40
- self .assertEqual (replace_word_choice ("Animals are cool." , "cool" , "awesome" ),
41
- "Animals are awesome." )
79
+
80
+ actual_result = replace_word_choice ("Animals are cool." , "cool" , "awesome" )
81
+ expected = "Animals are awesome."
82
+ error_message = ('Called replace_word_choice("Animals are cool.", "cool", "awesome"). '
83
+ f'The function returned "{ actual_result } ", '
84
+ f'but the tests expected "{ expected } " after the word replacement.' )
85
+
86
+ self .assertEqual (actual_result , expected , msg = error_message )
42
87
43
88
@pytest .mark .task (taskno = 4 )
44
89
def test_replace_word_not_exist (self ):
45
- self .assertEqual (replace_word_choice ("Animals are cool." , "small" , "tiny" ),
46
- "Animals are cool." )
90
+
91
+ actual_result = replace_word_choice ("Animals are cool." , "small" , "tiny" )
92
+ expected = "Animals are cool."
93
+ error_message = ('Called replace_word_choice("Animals are cool.", "small", "tiny"). '
94
+ f'The function returned "{ actual_result } ", '
95
+ f'but the tests expected "{ expected } ", because the word '
96
+ 'to be replaced is not in the sentence.' )
97
+
98
+ self .assertEqual (actual_result , expected , msg = error_message )
0 commit comments