From 9549a3e3d4be2a15c222996abff8cb97180ee9be Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 16 May 2016 15:22:01 +1200 Subject: Issue #26807: mock_open 'files' no longer error on readline at end of file. Patch from Yolanda Robla. --- Lib/unittest/mock.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Lib/unittest/mock.py') diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index cabae15214a..86a5a3dfebd 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -2323,6 +2323,8 @@ def mock_open(mock=None, read_data=''): yield handle.readline.return_value for line in _state[0]: yield line + while True: + yield type(read_data)() global file_spec -- cgit v1.2.3