summaryrefslogtreecommitdiff
path: root/Doc/library/unittest.mock.rst
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2013-03-19 17:22:51 -0700
committerMichael Foord <michael@voidspace.org.uk>2013-03-19 17:22:51 -0700
commit04cbe0c35b20c8379baf55cc5e152f88449e5202 (patch)
treec139e3a89936361190bcbfaa7d87d45043671254 /Doc/library/unittest.mock.rst
parent94f2788a859df7e79f8800f2b601e00acc2f8562 (diff)
downloadcpython-git-04cbe0c35b20c8379baf55cc5e152f88449e5202.tar.gz
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.rst8
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index c711565339..be637284e9 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::