From 49f6f42df2a4d57941b481aa5dde4f0330cb9c02 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Wed, 14 Oct 2026 22:17:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=9A=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=A2=AB=E6=95=B4=E4=BD=93=E6=8B=92=E6=94=B6=E7=9A=84=E4=B8=A4?= =?UTF-8?q?=E6=9D=A1=E6=96=AD=E8=A8=80=E6=94=B9=E4=B8=BA=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=89=8D=E5=90=8E=E7=9A=84=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=81=87=E5=AE=9A=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=BF=9B=E7=A8=8B=E9=87=8C=E5=88=AB=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=B2=A1=E6=94=B9=E8=BF=87=E5=AE=83=EF=BC=88?= =?UTF-8?q?=E5=B9=B6=E8=A1=8C=E5=85=A8=E9=87=8F=E6=97=B6=E6=8C=89=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E5=81=B6=E5=8F=91=E5=A4=B1=E8=B4=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/tests/test_catalog_draft_settings.py | 7 +++++-- backend/tests/test_verify_settings.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/tests/test_catalog_draft_settings.py b/backend/tests/test_catalog_draft_settings.py index d36e73e1..04c44f20 100644 --- a/backend/tests/test_catalog_draft_settings.py +++ b/backend/tests/test_catalog_draft_settings.py @@ -83,11 +83,14 @@ async def test_the_group_round_trips(client, providers): ("起草模型甲", "起草模型"), ]) async def test_bad_values_are_refused_with_the_settings_page_wording(client, providers, value, label): - r = await client.put("/api/settings", json={"values": {"catalog_draft": value, "ui": {"theme": "dark"}}}) + # 比的是这次请求前后:同一个测试进程里别的测试可能已经把主题存成了别的值,不能假定它不是 dark + before = (await client.get("/api/settings")).json()["ui"]["theme"] + wanted = "light" if before == "dark" else "dark" + r = await client.put("/api/settings", json={"values": {"catalog_draft": value, "ui": {"theme": wanted}}}) assert r.status_code == 422, r.text assert label in r.json()["detail"] got = (await client.get("/api/settings")).json() - assert got["catalog_draft"] == {"provider": None, "model": None} and got["ui"]["theme"] != "dark" + assert got["catalog_draft"] == {"provider": None, "model": None} and got["ui"]["theme"] == before @pytest.mark.parametrize("name,reason,fix", [ diff --git a/backend/tests/test_verify_settings.py b/backend/tests/test_verify_settings.py index e6a2c313..1c17bc50 100644 --- a/backend/tests/test_verify_settings.py +++ b/backend/tests/test_verify_settings.py @@ -123,13 +123,16 @@ async def test_a_partial_group_keeps_the_other_defaults_down_to_each_item(): ]) async def test_bad_values_are_refused_with_the_settings_page_wording(key, value, label): async with client() as c: - r = await c.put("/api/settings", json={"values": {"verify": {key: value}, "ui": {"theme": "dark"}}}) + # 比的是这次请求前后:同一个测试进程里别的测试可能已经把主题存成了别的值,不能假定它不是 dark + before = (await c.get("/api/settings")).json()["ui"]["theme"] + wanted = "light" if before == "dark" else "dark" + r = await c.put("/api/settings", json={"values": {"verify": {key: value}, "ui": {"theme": wanted}}}) assert r.status_code == 422, r.text detail = r.json()["detail"] # 报错写设置页上的叫法(「双盲复算 · 允许的相对误差」),不写键名;认不出的键原样点名 assert VERIFY_SETTING_LABEL.get(label, label.rpartition(".")[2]) in detail, detail got = (await c.get("/api/settings")).json() - assert got["verify"] == VERIFY_DEFAULTS and got["ui"]["theme"] != "dark", "整个请求都没写进去" + assert got["verify"] == VERIFY_DEFAULTS and got["ui"]["theme"] == before, "整个请求都没写进去" @pytest.mark.parametrize("raw", ["NaN", "Infinity"])