This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Enhancement: give mock_open readline() and readlines() methods
Type: enhancement Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder: mock_open() should allow reading binary data
View: 23004
Assigned To: michael.foord Nosy List: a.badger, michael.foord, python-dev
Priority: normal Keywords: needs review, patch

Created on 2013-03-18 20:09 by a.badger, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python3-mock_open-methods.patch a.badger, 2013-03-18 20:09 Patch mock_open to understand readline and readlines methods
01000-mock_open-methods.patch a.badger, 2013-03-19 16:46 2nd version of mock_open readline/readlines patch
01000-mock_open-methods.patch a.badger, 2013-03-19 19:17 3rd version of the mock_open patch -- docs and read/readline/readlines draw from the same read_data
Pull Requests
URL Status Linked Edit
PR 11523 merged remi.lapeyre, 2019-01-11 17:00
PR 11523 merged remi.lapeyre, 2019-01-11 17:00
PR 11523 merged remi.lapeyre, 2019-01-11 17:00
Messages (4)
msg184512 - (view) Author: Toshio Kuratomi (a.badger) * Date: 2013-03-18 20:09
unittest.mock provides a mock_open convenience function[1].  The convenience function handled file.read() but does not handle file.readline() or file.readlines().  I'll attach a patch that adds support for both of these methods.

[1]: http://docs.python.org/3/library/unittest.mock.html#mock-open
msg184642 - (view) Author: Toshio Kuratomi (a.badger) * Date: 2013-03-19 16:46
Updated patch that includes unittests and fixes readlines() newline behaviour.
msg184664 - (view) Author: Toshio Kuratomi (a.badger) * Date: 2013-03-19 19:17
3rd version of the patch.

* Added some documentation to untitest.mock.rst
* Changed the code so that read, readline, and readlines all deplete the same copy of read_data.
msg184714 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-20 00:22
New changeset 684b75600fa9 by Michael Foord in branch 'default':
Closes issue 17467. Add readline and readlines support to unittest.mock.mock_open
http://hg.python.org/cpython/rev/684b75600fa9
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61669
2019-01-11 17:00:56remi.lapeyresetpull_requests: + pull_request11103
2019-01-11 17:00:48remi.lapeyresetpull_requests: + pull_request11102
2019-01-11 17:00:41remi.lapeyresetpull_requests: + pull_request11101
2014-12-07 15:25:59jcealinkissue23004 dependencies
2014-12-07 15:25:42jceasetsuperseder: mock_open() should allow reading binary data
2013-03-20 00:22:57python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg184714

resolution: fixed
stage: patch review -> resolved
2013-03-19 19:17:32a.badgersetfiles: + 01000-mock_open-methods.patch

messages: + msg184664
2013-03-19 17:00:45michael.foordsetnosy: + michael.foord
versions: + Python 3.4, - Python 3.3
assignee: michael.foord
keywords: + needs review
type: enhancement
stage: patch review
2013-03-19 16:46:50a.badgersetfiles: + 01000-mock_open-methods.patch

messages: + msg184642
2013-03-18 20:09:13a.badgercreate