mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #21750: Further fixup to be styled like other mock APIs.
This commit is contained in:
parent
80e4f30e64
commit
ca647ef60a
4 changed files with 68 additions and 37 deletions
|
@ -1995,9 +1995,11 @@ mock_open
|
|||
:meth:`~io.IOBase.readline`, and :meth:`~io.IOBase.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.
|
||||
simplistic: every time the *mock* is called, the *read_data* is rewound to
|
||||
the start. 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. When that
|
||||
is insufficient, one of the in-memory filesystem packages on `PyPI
|
||||
<https://pypi.python.org/pypi>`_ can offer a realistic filesystem for testing.
|
||||
|
||||
Using :func:`open` as a context manager is a great way to ensure your file handles
|
||||
are closed properly and is becoming common::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue