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:
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 2013-03-20 00:22 by python-dev. 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
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) 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
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