@@ -7,19 +7,24 @@ def test_first_line(self):
7
7
with open ('output.txt' , 'r' ) as result :
8
8
lines = result .readlines ()
9
9
expected , actual = 'This is the output file. Do not modify this line :)\n ' , lines [0 ]
10
+ if expected != actual :
11
+ with open ('output.txt' , 'w' ) as result2 :
12
+ result2 .write ("This is the output file. Do not modify this line :)" )
10
13
self .assertEqual (expected , actual ,
11
- msg = 'The first line in the output file should remain "This is the output file.Do not modify this line :)".' )
14
+ msg = 'The first line in the output file should remain '
15
+ '"This is the output file. Do not modify this line :)".' )
16
+
17
+
12
18
def test_last_line (self ):
13
19
with open ('output.txt' , 'r' ) as result :
14
20
lines = result .readlines ()
15
21
actual = lines [- 1 ]
16
22
self .assertTrue ('15' == actual or '15\n ' == actual ,
17
- msg = 'The last line in the output should be "15".' )
23
+ msg = 'The last line in the output should be "15".' )
18
24
19
25
def test_second_to_last_line (self ):
20
26
with open ('output.txt' , 'r' ) as result :
21
27
lines = result .readlines ()
22
28
expected , actual = 'lion and elephant and monkey\n ' , lines [- 2 ]
23
29
self .assertEqual (expected , actual ,
24
30
msg = 'The second to last line in the output file should be "lion and elephant and monkey".' )
25
-
0 commit comments