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

Function client

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

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

(test_engine)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected