Skip to content

Commit 875f163

Browse files
committed
Python 3 test_finding_lines2() assert passes as-is
Fixes issue gregmalcolm#169, reported in @denis-roy's pull request gregmalcolm#157: The Python 3 version of AboutWithStatements.test_finding_lines2 contains an assertNotEqual(__, ...) that passes without the student having to change anything. I think the idea was that the assertNotEqual would test that the student-written function returns _anything_ (by default, the pass statement returns None), while the assertEqual would test that furthermore the return value is correct. In this version, the general (not-None) assertion is tested before the specific. Also, both assertions have the passing / expected values hard-coded, meaning the student should change only the function they test, not the assertions themselves.
1 parent f4b2b8d commit 875f163

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

python2/koans/about_with_statements.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ def test_counting_lines2(self):
9191
# ------------------------------------------------------------------
9292

9393
def find_line2(self, file_name):
94-
# Rewrite find_line using the Context Manager.
95-
pass
94+
# Using the context manager self.FileContextManager, rewrite this
95+
# function to return the first line containing the letter 'e'.
96+
return None
9697

9798
def test_finding_lines2(self):
98-
self.assertEqual(__, self.find_line2("example_file.txt"))
9999
self.assertNotEqual(None, self.find_line2("example_file.txt"))
100+
self.assertEqual('test\n', self.find_line2("example_file.txt"))
100101

101102
# ------------------------------------------------------------------
102103

python3/koans/about_with_statements.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ def test_counting_lines2(self):
9090
# ------------------------------------------------------------------
9191

9292
def find_line2(self, file_name):
93-
# Rewrite find_line using the Context Manager.
94-
pass
93+
# Using the context manager self.FileContextManager, rewrite this
94+
# function to return the first line containing the letter 'e'.
95+
return None
9596

9697
def test_finding_lines2(self):
97-
self.assertEqual(__, self.find_line2("example_file.txt"))
98-
self.assertNotEqual(__, self.find_line2("example_file.txt"))
98+
self.assertNotEqual(None, self.find_line2("example_file.txt"))
99+
self.assertEqual('test\n', self.find_line2("example_file.txt"))
99100

100101
# ------------------------------------------------------------------
101102

0 commit comments

Comments
 (0)