守住 V2 import 清理狀態
This commit is contained in:
@@ -81,6 +81,21 @@ def test_scheduler_does_not_silently_swallow_exceptions():
|
||||
assert not re.search(r"except(?: Exception)?[^\n]*:\n\s+pass(?:\s|#|$)", scheduler_source)
|
||||
|
||||
|
||||
def test_v2_flagged_imports_are_removed_or_active():
|
||||
app_source = (ROOT / "app.py").read_text(encoding="utf-8")
|
||||
scheduler_source = (ROOT / "scheduler.py").read_text(encoding="utf-8")
|
||||
|
||||
for module_name in ["math", "hashlib", "zipfile", "io", "traceback"]:
|
||||
assert not re.search(rf"^\s*import\s+{module_name}\b", app_source, re.MULTILINE)
|
||||
assert "EXCEL_EXPORT_DIR" not in app_source
|
||||
assert "DATABASE_TYPE" not in app_source
|
||||
|
||||
assert re.search(r"^\s*import\s+schedule\b", app_source, re.MULTILINE)
|
||||
assert "schedule.run_pending()" in app_source
|
||||
assert "schedule.every(" in app_source
|
||||
assert not re.search(r"^\s*import\s+schedule\b", scheduler_source, re.MULTILINE)
|
||||
|
||||
|
||||
def test_tracked_backup_artifacts_stay_removed():
|
||||
forbidden_artifacts = [
|
||||
"app.py.backup_login_required",
|
||||
|
||||
Reference in New Issue
Block a user