MCPcopy Create free account
hub / github.com/espnet/espnet / test_parallel_map_internal_client

Function test_parallel_map_internal_client

test/espnet3/parallel/test_parallel.py:155–172  ·  view source on GitHub ↗
(local_cfg, monkeypatch)

Source from the content-addressed store, hash-verified

153
154@pytest.mark.execution_timeout(30)
155def test_parallel_map_internal_client(local_cfg, monkeypatch):
156 # Test the branch where client=None and get_client() is internally used
157 class _Ctx:
158 def __init__(self, client):
159 self.client = client
160
161 def __enter__(self):
162 return self.client
163
164 def __exit__(self, exc_type, exc, tb):
165 self.client.close()
166
167 cli = build_client(local_cfg)
168 monkeypatch.setattr(
169 "espnet3.parallel.parallel.get_client", lambda *a, **k: _Ctx(cli)
170 )
171 res = parallel_map(lambda x: x * 2, [1, 2, 3])
172 assert res == [2, 4, 6]
173
174
175# ------------------------------------------------------------

Callers

nothing calls this directly

Calls 3

build_clientFunction · 0.90
parallel_mapFunction · 0.90
_CtxClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…