diff options
author | Michael Foord <michael@voidspace.org.uk> | 2013-03-20 00:22:51 (GMT) |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2013-03-20 00:22:51 (GMT) |
commit | 04cbe0c35b20c8379baf55cc5e152f88449e5202 (patch) | |
tree | c139e3a89936361190bcbfaa7d87d45043671254 /Doc/library/unittest.mock.rst | |
parent | 94f2788a859df7e79f8800f2b601e00acc2f8562 (diff) | |
download | cpython-04cbe0c35b20c8379baf55cc5e152f88449e5202.zip cpython-04cbe0c35b20c8379baf55cc5e152f88449e5202.tar.gz cpython-04cbe0c35b20c8379baf55cc5e152f88449e5202.tar.bz2 |
Closes issue 17467. Add readline and readlines support to unittest.mock.mock_open
Diffstat (limited to 'Doc/library/unittest.mock.rst')
-rw-r--r-- | Doc/library/unittest.mock.rst | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index c711565..be63728 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -1989,8 +1989,12 @@ mock_open default) then a `MagicMock` will be created for you, with the API limited to methods or attributes available on standard file handles. - `read_data` is a string for the `read` method of the file handle to return. - This is an empty string by default. + `read_data` is a string for the `read`, `readline`, and `readlines` methods + of the file handle to return. Calls to those methods will take data from + `read_data` until it is depleted. The mock of these methods is pretty + simplistic. If you need more control over the data that you are feeding to + the tested code you will need to customize this mock for yourself. + `read_data` is an empty string by default. Using `open` as a context manager is a great way to ensure your file handles are closed properly and is becoming common:: |