This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mock_open file handle __exit__ does not call close
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: CendioOssman, michael.foord, sametyaslan, williamsjoblom, xtreak
Priority: normal Keywords: patch

Created on 2021-05-20 08:17 by williamsjoblom, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 26902 open sametyaslan, 2021-06-24 19:02
Messages (1)
msg394005 - (view) Author: William Sjoblom (williamsjoblom) Date: 2021-05-20 08:17
A common testing scenario is assuring that opened files are closed. Since unittest.mock.mock_open() can be used as a context manager, it would be reasonable to expect its __exit__ to invoke close so that one can easily assert that the file was closed, regardless of if the file was opened with a plain call to open or with a context manager.
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88351
2021-06-26 15:05:02terry.reedysetnosy: + michael.foord

versions: - Python 3.6, Python 3.7, Python 3.8
2021-06-24 19:02:26sametyaslansetkeywords: + patch
nosy: + sametyaslan

pull_requests: + pull_request25478
stage: patch review
2021-05-20 14:35:37CendioOssmansetnosy: + CendioOssman
2021-05-20 08:39:23xtreaksetnosy: + xtreak
2021-05-20 08:17:05williamsjoblomcreate