fix: restore requests module after test_lazy_imports_requests

Use monkeypatch.delitem instead of manual del sys.modules['requests']
so pytest automatically restores the module after the test. This
prevents 12 downstream Google auth/music/Veo tests from failing with
AttributeError: module 'requests' has no attribute 'exceptions'.

Fixes calesthio's review feedback on PR #341.
This commit is contained in:
Yiyabo
2026-07-13 12:55:27 +08:00
parent 2ad71dd591
commit 8414c485ad

View File

@@ -107,12 +107,12 @@ class TestContract:
def test_has_user_visible_verification(self):
assert len(JimengVideo().user_visible_verification) > 0
def test_lazy_imports_requests(self):
def test_lazy_imports_requests(self, monkeypatch):
import importlib
import sys
mod_name = "tools.video.jimeng_video"
if "requests" in sys.modules:
del sys.modules["requests"]
monkeypatch.delitem(sys.modules, "requests")
importlib.reload(sys.modules[mod_name])
def test_estimate_cost_returns_float(self):