MCPcopy
hub / github.com/pydata/xarray / register_dummy_chunkmanager

Function register_dummy_chunkmanager

xarray/tests/test_parallelcompat.py:132–149  ·  view source on GitHub ↗

Mocks the registering of an additional ChunkManagerEntrypoint. This preserves the presence of the existing DaskManager, so a test that relies on this and DaskManager both being returned from list_chunkmanagers() at once would still work. The monkeypatching changes the behavior of

(monkeypatch)

Source from the content-addressed store, hash-verified

130
131@pytest.fixture
132def register_dummy_chunkmanager(monkeypatch):
133 """
134 Mocks the registering of an additional ChunkManagerEntrypoint.
135
136 This preserves the presence of the existing DaskManager, so a test that relies on this and DaskManager both being
137 returned from list_chunkmanagers() at once would still work.
138
139 The monkeypatching changes the behavior of list_chunkmanagers when called inside xarray.namedarray.parallelcompat,
140 but not when called from this tests file.
141 """
142 # Should include DaskManager iff dask is available to be imported
143 preregistered_chunkmanagers = list_chunkmanagers()
144
145 monkeypatch.setattr(
146 "xarray.namedarray.parallelcompat.list_chunkmanagers",
147 lambda: {"dummy": DummyChunkManager()} | preregistered_chunkmanagers,
148 )
149 yield
150
151
152class TestGetChunkManager:

Callers

nothing calls this directly

Calls 2

list_chunkmanagersFunction · 0.90
DummyChunkManagerClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…