-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
def test_person_class_with_mock(mocker):
"""
Test the Person class using a mock for the 'get_person_json' method
"""
person = Person(name="Eric", age=25, address="123 Farmville Rd")
mock_response = {"name": "FAKE_NAME", "age": "FAKE_AGE", "address": "FAKE_ADDRESS"}
# Patch the method
mocker.patch.object(person, "get_person_json", return_value=mock_response)
assert person.get_person_json() == mock_response
I could not understand the combination of return_value=mock_response) and assert person.get_person_json() == mock_response
It seems like no matter how get_person_json is implemented, the return_value is forced to equal mock_response, then of course the assert will be True, making this test redundant.
Why ever do this pattern? What is it testing?
Metadata
Metadata
Assignees
Labels
No labels