[New-bugs-announce] [issue44185] mock_open file handle __exit__ does not call close

William Sjoblom report at bugs.python.org
Thu May 20 04:17:05 EDT 2021

New submission from William Sjoblom <wllmsjblm at gmail.com>:

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.

components: Library (Lib)
messages: 394005
nosy: williamsjoblom
priority: normal
severity: normal
status: open
title: mock_open file handle __exit__ does not call close
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list