bpo-32933: Implement __iter__ method on mock_open() (GH-5974)
(cherry picked from commit 2087023fdec2c89070bd14f384a3c308c548a94a)
Co-authored-by: Tony Flury <anthony.flury@btinternet.com>
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index fb325ed..ef1b2e3 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -2095,6 +2095,10 @@
.. versionchanged:: 3.5
*read_data* is now reset on each call to the *mock*.
+ .. versionchanged:: 3.7.1
+ Added :meth:`__iter__` to implementation so that iteration (such as in for
+ loops) correctly consumes *read_data*.
+
Using :func:`open` as a context manager is a great way to ensure your file handles
are closed properly and is becoming common::