style: run the formatter over the issue 14 changes

ruff format only; no semantic change.
This commit is contained in:
2026-08-20 00:44:21 -04:00
parent d9ceaecf20
commit 5a025b6e5d
5 changed files with 38 additions and 20 deletions
-1
View File
@@ -291,7 +291,6 @@ class TestRetryAfter:
await _open_gate(gate, "s1") # s1 开路;s2 健康
assert await gate.retry_after_s(("s1", "s2")) == 0.0
async def test_half_open_rejection_reports_no_certain_wait(self, gate_factory, clock):
"""探针在途时被拒 → 0.0(issue #14): 探针随时可能出结果,不存在确定时刻。
+35 -10
View File
@@ -628,8 +628,12 @@ class TestCircuitOpenPolicy:
clock = FakeClock()
src = make_source()
mw = _mw(
[src], self._free_limiter(clock, src), [], clock=clock,
sleep=BoundedSleep(), gate=await self._opened_gate(clock),
[src],
self._free_limiter(clock, src),
[],
clock=clock,
sleep=BoundedSleep(),
gate=await self._opened_gate(clock),
)
with pytest.raises(CircuitOpenError) as ei:
await mw(_REQ)
@@ -650,8 +654,13 @@ class TestCircuitOpenPolicy:
sleep._side_effect = advance
mw = _mw(
[src], self._free_limiter(clock, src), [_ok()], clock=clock,
sleep=sleep, gate=await self._opened_gate(clock), circuit_open="wait",
[src],
self._free_limiter(clock, src),
[_ok()],
clock=clock,
sleep=sleep,
gate=await self._opened_gate(clock),
circuit_open="wait",
)
resp = await mw(_REQ)
assert resp.content == "ok"
@@ -671,8 +680,14 @@ class TestCircuitOpenPolicy:
sleep._side_effect = advance
mw = _mw(
[src], self._free_limiter(clock, src), [_ok()], clock=clock, sleep=sleep,
gate=await self._opened_gate(clock), quota_full="fail_fast", circuit_open="wait",
[src],
self._free_limiter(clock, src),
[_ok()],
clock=clock,
sleep=sleep,
gate=await self._opened_gate(clock),
quota_full="fail_fast",
circuit_open="wait",
)
assert (await mw(_REQ)).content == "ok"
@@ -694,8 +709,13 @@ class TestCircuitOpenPolicy:
sleep._side_effect = advance
mw = _mw(
[src], self._free_limiter(clock, src), [], clock=clock, sleep=sleep,
gate=await self._opened_gate(clock, long_cooldown), circuit_open="wait",
[src],
self._free_limiter(clock, src),
[],
clock=clock,
sleep=sleep,
gate=await self._opened_gate(clock, long_cooldown),
circuit_open="wait",
)
with pytest.raises(AllSourcesExhausted) as ei:
await mw(_REQ)
@@ -708,8 +728,13 @@ class TestCircuitOpenPolicy:
clock = FakeClock()
src = make_source()
mw = _mw(
[src], self._free_limiter(clock, src), [], clock=clock,
sleep=asyncio.sleep, gate=await self._opened_gate(clock), circuit_open="wait",
[src],
self._free_limiter(clock, src),
[],
clock=clock,
sleep=asyncio.sleep,
gate=await self._opened_gate(clock),
circuit_open="wait",
)
task = asyncio.create_task(mw(_REQ))
await asyncio.sleep(0.03)
+1 -3
View File
@@ -177,9 +177,7 @@ class TestResilienceKeys:
"快速失败 → 长时间挂起"这个最危险的方向,不能强加给存量下游。
"""
assert GatewaySettings.from_env("LLM", env=_env()).circuit_open == "fail_fast"
waiting = GatewaySettings.from_env(
"LLM", env=_env(**{"LLM__CIRCUIT_OPEN": "wait"})
)
waiting = GatewaySettings.from_env("LLM", env=_env(**{"LLM__CIRCUIT_OPEN": "wait"}))
assert waiting.circuit_open == "wait"
with pytest.raises(ValueError, match="CIRCUIT_OPEN"):
GatewaySettings.from_env("LLM", env=_env(**{"LLM__CIRCUIT_OPEN": "block"}))