MCPcopy Create free account
hub / github.com/Tong89/smartNode / client

Function client

tests/test_api.py:47–61  ·  view source on GitHub ↗

将干净引擎注入 api.app,返回 Flask test_client。 测试结束后恢复原始引擎,避免全局状态污染。

(_engine)

Source from the content-addressed store, hash-verified

45
46@pytest.fixture
47def client(_engine):
48 """将干净引擎注入 api.app,返回 Flask test_client。
49
50 测试结束后恢复原始引擎,避免全局状态污染。
51 """
52 import backend.api as api_module
53
54 original = api_module.simulation_engine
55 api_module.simulation_engine = _engine
56 api_module.app.config["TESTING"] = True
57 try:
58 with api_module.app.test_client() as c:
59 yield c
60 finally:
61 api_module.simulation_engine = original
62
63
64# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected