Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

#23004: mock_open() should allow reading binary data

Can't Edit
Can't Publish+Mail
Start Review
Created:
5 years, 5 months ago by jcea
Modified:
5 years, 5 months ago
Reviewers:
demianbrecht, berker.peksag
CC:
jcea, rbcollins, a.badger, r.david.murray, Michael Foord, devnull_psf.upfronthosting.co.za, berkerpeksag, Aaron1011
Visibility:
Public.

Patch Set 1 #

Patch Set 2 #

Patch Set 3 #

Total comments: 2

Patch Set 4 #

Total comments: 4

Patch Set 5 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/unittest/mock.py View 1 2 3 4 2 chunks +6 lines, -3 lines 0 comments Download
Lib/unittest/test/testmock/testwith.py View 1 2 3 4 1 chunk +16 lines, -0 lines 0 comments Download

Messages

Total messages: 2
demian
http://bugs.python.org/review/23004/diff/13416/Lib/unittest/mock.py File Lib/unittest/mock.py (right): http://bugs.python.org/review/23004/diff/13416/Lib/unittest/mock.py#newcode2269 Lib/unittest/mock.py:2269: if type(read_data) == bytes: No need for the redundant ...
5 years, 5 months ago #1
berkerpeksag
5 years, 5 months ago #2
http://bugs.python.org/review/23004/diff/13422/Lib/unittest/test/testmock/tes...
File Lib/unittest/test/testmock/testwith.py (right):

http://bugs.python.org/review/23004/diff/13422/Lib/unittest/test/testmock/tes...
Lib/unittest/test/testmock/testwith.py:214: m = mock_open(read_data=b'\xc6')
m -> mock

http://bugs.python.org/review/23004/diff/13422/Lib/unittest/test/testmock/tes...
Lib/unittest/test/testmock/testwith.py:215: with patch('%s.open' % __name__, m,
create=True) :
Remove whitespace before ``:``.

http://bugs.python.org/review/23004/diff/13422/Lib/unittest/test/testmock/tes...
Lib/unittest/test/testmock/testwith.py:217: self.assertEqual(f.read(), b'\xc6')
I'd write this like below to be consistent with the current style.

with patch('%s.open' % __name__, m, create=True):
    with open('abc', 'rb') as fobj:
        result = fobj.read()

self.assertEqual(result, b'\xc6')

http://bugs.python.org/review/23004/diff/13422/Lib/unittest/test/testmock/tes...
Lib/unittest/test/testmock/testwith.py:222: with patch('%s.open' % __name__, m,
create=True) :
Remove whitespace before ``:``.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+