完成 Ruff 全量清理
This commit is contained in:
@@ -175,18 +175,21 @@ class TestHuyaAppLogin:
|
||||
side_effect=DfpRegistrationError("注册链超时"),
|
||||
) as m_reg,
|
||||
patch("core.huya.app_login.requests.post") as m_post,
|
||||
pytest.raises(HuyaAppLoginError),
|
||||
):
|
||||
with pytest.raises(HuyaAppLoginError):
|
||||
wup_password_login_raw("300023887", "pw")
|
||||
wup_password_login_raw("300023887", "pw")
|
||||
m_reg.assert_called_once()
|
||||
m_post.assert_not_called()
|
||||
|
||||
def test_login_cred_flow_registration_failure_is_explicit(self):
|
||||
"""login_cred_with_flow 注册失败同样包装为 HuyaAppLoginError 显式失败。"""
|
||||
with patch(
|
||||
"core.huya.app_login.register_device",
|
||||
side_effect=DfpRegistrationError("注册链 HTTP 500"),
|
||||
), pytest.raises(HuyaAppLoginError, match="注册失败"):
|
||||
with (
|
||||
patch(
|
||||
"core.huya.app_login.register_device",
|
||||
side_effect=DfpRegistrationError("注册链 HTTP 500"),
|
||||
),
|
||||
pytest.raises(HuyaAppLoginError, match="注册失败"),
|
||||
):
|
||||
login_cred_with_flow("300023887", "pw")
|
||||
|
||||
def test_router_functions(self):
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import gzip
|
||||
import logging
|
||||
import tempfile
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
from utils.logger import (
|
||||
@@ -40,7 +40,8 @@ class TestLogger:
|
||||
|
||||
archives = list(Path(tmpdir).glob("app-2026-08-28.log.*.gz"))
|
||||
assert len(archives) == 1
|
||||
archived_content = gzip.open(archives[0], "rt", encoding="utf-8").read()
|
||||
with gzip.open(archives[0], "rt", encoding="utf-8") as archive:
|
||||
archived_content = archive.read()
|
||||
current_content = log_path.read_text(encoding="utf-8")
|
||||
combined = archived_content + current_content
|
||||
assert "super-secret" not in combined
|
||||
@@ -50,7 +51,7 @@ class TestLogger:
|
||||
|
||||
def test_daily_log_switches_to_a_new_dated_file(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
today = datetime.now().date()
|
||||
today = datetime.now(UTC).date()
|
||||
old_path = (
|
||||
Path(tmpdir) / f"app-{(today - timedelta(days=1)).isoformat()}.log"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user