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.

Author CendioOssman
Recipients CendioOssman
Date 2021-06-24.11:08:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624532935.8.0.760752273219.issue44503@roundup.psfhosted.org>
In-reply-to
Content
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")
History
Date User Action Args
2021-06-24 11:08:55CendioOssmansetrecipients: + CendioOssman
2021-06-24 11:08:55CendioOssmansetmessageid: <1624532935.8.0.760752273219.issue44503@roundup.psfhosted.org>
2021-06-24 11:08:55CendioOssmanlinkissue44503 messages
2021-06-24 11:08:55CendioOssmancreate