(file_cache)
| 23 | |
| 24 | |
| 25 | def test_file_manager_mock_write(file_cache) -> None: |
| 26 | mock_file = mock.Mock() |
| 27 | opener = mock.Mock(spec=open, return_value=mock_file) |
| 28 | lock = mock.MagicMock(spec=threading.Lock()) |
| 29 | |
| 30 | manager = CachingFileManager(opener, "filename", lock=lock, cache=file_cache) |
| 31 | f = manager.acquire() |
| 32 | f.write("contents") |
| 33 | manager.close() |
| 34 | |
| 35 | assert not file_cache |
| 36 | opener.assert_called_once_with("filename") |
| 37 | mock_file.write.assert_called_once_with("contents") |
| 38 | mock_file.close.assert_called_once_with() |
| 39 | lock.__enter__.assert_has_calls([mock.call(), mock.call()]) |
| 40 | |
| 41 | |
| 42 | @pytest.mark.parametrize("warn_for_unclosed_files", [True, False]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…