You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function's own docstring: "read_data is a string ... This is an empty string by default."
At runtime: inspect.signature(mock_open) returns (mock=None, read_data='')
The code default was changed from None to '' in 2012 (commit 0dccf657b51, "Minor changes to the unittest.mock.mock_open helper"), but the documented signature was never updated. The surrounding prose already describes read_data as "a string", so the None in the signature is stale and slightly misleading.
The documentation for
unittest.mock.mock_opengives the signature as:but the actual default for
read_datais the empty string, notNone:Lib/unittest/mock.py:def mock_open(mock=None, read_data=''):read_datais a string ... This is an empty string by default."inspect.signature(mock_open)returns(mock=None, read_data='')The code default was changed from
Noneto''in 2012 (commit0dccf657b51, "Minor changes to the unittest.mock.mock_open helper"), but the documented signature was never updated. The surrounding prose already describesread_dataas "a string", so theNonein the signature is stale and slightly misleading.Linked PRs
unittest.mock.mock_open'sread_dataparameter (GH-151444) #151450unittest.mock.mock_open'sread_dataparameter (GH-151444) #151451unittest.mock.mock_open'sread_dataparameter (GH-151444) #151452