From a7be2adbbb67bec713303364b75b599ce1e51eb9 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 19 May 2026 16:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=EF=BC=9AAM?= =?UTF-8?q?SC/NMC=20=E7=94=A8=20monkeypatch.setattr=20=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=BA=A7=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_amsc_awos_sources.py | 3 ++- tests/test_nmc_sources.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_amsc_awos_sources.py b/tests/test_amsc_awos_sources.py index 52d7fece..440aa60c 100644 --- a/tests/test_amsc_awos_sources.py +++ b/tests/test_amsc_awos_sources.py @@ -74,7 +74,8 @@ def test_parse_wind_plate_payload_rejects_unauthorized_or_empty_payloads(): def test_fetch_amsc_official_current_uses_domestic_city_whitelist(monkeypatch): - monkeypatch.setenv("AMSC_AWOS_BASE_URL", "https://www.amsc.net.cn/gateway/api/saas/rest/amc/AwosController/getWindPlate") + import src.data_collection.amsc_awos_sources as _amsc + monkeypatch.setattr(_amsc, "AMSC_AWOS_BASE_URL", "https://www.amsc.net.cn/gateway/api/saas/rest/amc/AwosController/getWindPlate") assert _amsc_supported_city_codes()["beijing"] == "ZBAA" assert "new york" not in _amsc_supported_city_codes() diff --git a/tests/test_nmc_sources.py b/tests/test_nmc_sources.py index 4caf1eea..3240cc30 100644 --- a/tests/test_nmc_sources.py +++ b/tests/test_nmc_sources.py @@ -41,7 +41,8 @@ class _DummyCollector(NmcSourceMixin): def test_fetch_nmc_region_current_parses_rest_payload(monkeypatch): - monkeypatch.setenv("NMC_REALTIME_BASE_URL", "https://www.nmc.cn/rest/real") + import src.data_collection.nmc_sources as _nmc + monkeypatch.setattr(_nmc, "_NMC_REALTIME_BASE", "https://www.nmc.cn/rest/real") collector = _DummyCollector( { "https://www.nmc.cn/rest/real/atcMf": _DummyResponse( @@ -72,7 +73,8 @@ def test_fetch_nmc_region_current_parses_rest_payload(monkeypatch): def test_fetch_nmc_official_nearby_returns_normalized_row(monkeypatch): - monkeypatch.setenv("NMC_REALTIME_BASE_URL", "https://www.nmc.cn/rest/real") + import src.data_collection.nmc_sources as _nmc + monkeypatch.setattr(_nmc, "_NMC_REALTIME_BASE", "https://www.nmc.cn/rest/real") collector = _DummyCollector( { "https://www.nmc.cn/rest/real/atcMf": _DummyResponse(