Author jcea
Recipients a.badger, jcea, michael.foord
Date 2014-12-07.15:24:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1417965857.24.0.521739131396.issue23004@psf.upfronthosting.co.za>
In-reply-to
Content
mock_open(read_data=b'...') gives an error:

"""Traceback (most recent call last):
  File "z.py", line 6, in <module>
    print(f.read())
  File "/usr/local/lib/python3.4/unittest/mock.py", line 896, in __call__
    return _mock_self._mock_call(*args, **kwargs)
  File "/usr/local/lib/python3.4/unittest/mock.py", line 962, in _mock_call
    ret_val = effect(*args, **kwargs)
  File "/usr/local/lib/python3.4/unittest/mock.py", line 2279, in _read_side_effect
    return ''.join(_data)
  File "/usr/local/lib/python3.4/unittest/mock.py", line 2244, in _iterate_read_data
    data_as_list = ['{}\n'.format(l) for l in read_data.split('\n')]
"""

Easy to reproduce:

"""
from unittest.mock import mock_open, patch

m = mock_open(read_data= b'abc')
with patch('__main__.open', m, create=True) :
    with open('abc', 'rb') as f :
        print(f.read())
"""

Looks like this bug was introduced as result of issue #17467. I add those people to the nosy list.
History
Date User Action Args
2014-12-07 15:24:17jceasetrecipients: + jcea, a.badger, michael.foord
2014-12-07 15:24:17jceasetmessageid: <1417965857.24.0.521739131396.issue23004@psf.upfronthosting.co.za>
2014-12-07 15:24:17jcealinkissue23004 messages
2014-12-07 15:24:16jceacreate