使用 TestClient 和 with 语句,在测试中运行事件处理器(startup 与 shutdown)。
TestClient
with
startup
shutdown
{* ../../docs_src/app_testing/tutorial003.py hl[9:12,20:24] *}