New submission from Pierre Ossman <oss...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue44503> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com