tests: centralize script path setup in conftest.py

Add a pytest-discovered tests/conftest.py for the last30days scripts path and
remove duplicate per-file sys.path.insert boilerplate from tests.

Normalize affected imports to rely on the shared scripts path and remove the
now-unneeded E402 suppressions.
This commit is contained in:
Yong-yuan-X
2026-05-20 23:16:07 +08:00
parent 850c7e0185
commit e74b0e1e93
84 changed files with 194 additions and 578 deletions
-7
View File
@@ -1,8 +1,4 @@
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "skills" / "last30days" / "scripts"))
from lib import fusion, schema
@@ -52,7 +48,6 @@ class FusionV3Tests(unittest.TestCase):
self.assertEqual({"reddit", "x"}, set(merged.sources))
self.assertEqual(2, len(merged.source_items))
def test_diversify_pool_guarantees_min_per_qualifying_source(self):
"""Every qualifying source (local_relevance >= 0.25) gets at least 2
items in the fused pool.
@@ -118,7 +113,6 @@ class FusionV3Tests(unittest.TestCase):
f"Source '{src}' has {source_counts.get(src, 0)} items, expected >= 2",
)
def test_diversify_pool_denies_slots_for_low_relevance_source(self):
"""Sources with best local_relevance < 0.25 do not get reserved slots.
@@ -439,6 +433,5 @@ class TestUrlNormalization(unittest.TestCase):
_normalize_url("https://reddit.com/r/test"),
)
if __name__ == "__main__":
unittest.main()