Index: Python-3.3.0/Lib/unittest/mock.py =================================================================== --- Python-3.3.0.orig/Lib/unittest/mock.py +++ Python-3.3.0/Lib/unittest/mock.py @@ -2188,6 +2188,8 @@ def mock_open(mock=None, read_data=''): handle.write.return_value = None handle.__enter__.return_value = handle handle.read.return_value = read_data + handle.readline.side_effect = map(lambda x: '{}\n'.format(x), read_data.split('\n')) + handle.readlines.return_value = list(map(lambda x: '{}\n'.format(x), read_data.split('\n'))) mock.return_value = handle return mock