Skip to content

AboutWithStatements.test_finding_lines2 (Python3 version) --- assertNotEqual passes as-is #169

@kjc

Description

@kjc

Quoting @denis-roy's pull request #157, regarding the Python 3 version of AboutWithStatements.test_finding_lines2:

The default placeholder value of __ can be left as is and the test will pass.

And from his comment in the file itself:

[...] In fact it accepts anything that is not 'test\n' as an answer.

The Python 2 version of the same test explicitly asserts that the user-written function does not return None:

def find_line2(self, file_name):
    # Rewrite find_line using the Context Manager.
    pass

def test_finding_lines2(self):
    self.assertEqual(__, self.find_line2("example_file.txt"))
    self.assertNotEqual(None, self.find_line2("example_file.txt"))

I think the idea was that the assertNotEqual would test that the student-written function returns anything, while the assertEqual would test that furthermore the return value is correct. That would be more clear if:

  1. The general test appeared before the specific test.

...and maybe:

  1. They both asserted the expected value.

Something like:

def test_finding_lines2(self):
    self.assertNotEqual(None, self.find_line2("example_file.txt"))
    self.assertEqual("test\n", self.find_line2("example_file.txt"))

This should focus the student's attention entirely on rewriting find_line2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions