Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3d8bf27

Browse files
committedMar 16, 2023
closes #177
1 parent 03ae245 commit 3d8bf27

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

Diff for: ‎File input output/Write to file/tests/test_task.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ def test_first_line(self):
77
with open('output.txt', 'r') as result:
88
lines = result.readlines()
99
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 :)")
1013
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+
1218
def test_last_line(self):
1319
with open('output.txt', 'r') as result:
1420
lines = result.readlines()
1521
actual = lines[-1]
1622
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".')
1824

1925
def test_second_to_last_line(self):
2026
with open('output.txt', 'r') as result:
2127
lines = result.readlines()
2228
expected, actual = 'lion and elephant and monkey\n', lines[-2]
2329
self.assertEqual(expected, actual,
2430
msg='The second to last line in the output file should be "lion and elephant and monkey".')
25-

0 commit comments

Comments
 (0)
Please sign in to comment.