You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
We'd like this change to uphold a good test principle of testing behaviour, not implementation. I.e. we want to test that the code closes the file, not how it closes it. So changing the code from explicitly calling close() to using a context manager (or vice versa) shouldn't require a change to the test.