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

Function test_refresh_engines

xarray/tests/test_plugins.py:332–361  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

330
331
332def test_refresh_engines() -> None:
333 from xarray.backends import list_engines, refresh_engines
334
335 EntryPointMock1 = mock.MagicMock()
336 EntryPointMock1.name = "test1"
337 EntryPointMock1.load.return_value = DummyBackendEntrypoint1
338
339 return_value = EntryPoints([EntryPointMock1])
340
341 with mock.patch("xarray.backends.plugins.entry_points", return_value=return_value):
342 list_engines.cache_clear()
343 engines = list_engines()
344 assert "test1" in engines
345 assert isinstance(engines["test1"], DummyBackendEntrypoint1)
346
347 EntryPointMock2 = mock.MagicMock()
348 EntryPointMock2.name = "test2"
349 EntryPointMock2.load.return_value = DummyBackendEntrypoint2
350
351 return_value2 = EntryPoints([EntryPointMock2])
352
353 with mock.patch("xarray.backends.plugins.entry_points", return_value=return_value2):
354 refresh_engines()
355 engines = list_engines()
356 assert "test1" not in engines
357 assert "test2" in engines
358 assert isinstance(engines["test2"], DummyBackendEntrypoint2)
359
360 # reset to original
361 refresh_engines()

Callers

nothing calls this directly

Calls 2

list_enginesFunction · 0.90
refresh_enginesFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…