MCPcopy Index your code
hub / github.com/pydata/xarray / test_file_manager_mock_write

Function test_file_manager_mock_write

xarray/tests/test_backends_file_manager.py:25–39  ·  view source on GitHub ↗
(file_cache)

Source from the content-addressed store, hash-verified

23
24
25def 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])

Callers

nothing calls this directly

Calls 3

acquireMethod · 0.95
closeMethod · 0.95
CachingFileManagerClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…