[New-bugs-announce] [issue44503] Hide __enter__ calls in mock_open
Pierre Ossman
report at bugs.python.org
Thu Jun 24 07:08:55 EDT 2021
New submission from Pierre Ossman <ossman at cendio.se>:
I'd like to write this test case:
with patch('builtins.open') as pyopen:
mock_open(pyopen, read_data="foo")
run()
pyopen.assert_has_calls([call("filename", "wt"),
call().write("gazonk"),
call().close()])
and I shouldn't have to care if the code is written like this:
def run():
f = open("filename", "wt")
try:
write("gazonk")
finally:
f.close()
or like this:
def run():
with open("filename", "wt") as f:
write("gazonk")
----------
components: Library (Lib)
messages: 396469
nosy: CendioOssman
priority: normal
severity: normal
status: open
title: Hide __enter__ calls in mock_open
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44503>
_______________________________________
More information about the New-bugs-announce
mailing list