MCPcopy Create free account
hub / github.com/mlco2/codecarbon / conditional_open_func

Function conditional_open_func

tests/testutils.py:25–31  ·  view source on GitHub ↗
(path, *args, **kwargs)

Source from the content-addressed store, hash-verified

23def get_custom_mock_open(global_conf_str, local_conf_str) -> callable:
24 def mocked_open():
25 def conditional_open_func(path, *args, **kwargs):
26 p = Path(path).expanduser().resolve()
27 if p.name == ".codecarbon.config":
28 if p.parent == Path.home():
29 return mock_open(read_data=global_conf_str)()
30 return mock_open(read_data=local_conf_str)()
31 return OPEN(path, *args, **kwargs)
32
33 return conditional_open_func
34

Callers

nothing calls this directly

Calls 1

mock_openFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…