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:
@@ -5,19 +5,16 @@ import urllib.error
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Ensure lib is importable
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "skills", "last30days", "scripts"))
|
||||
|
||||
from lib import reddit_public
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Fixtures / helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _make_reddit_listing(posts):
|
||||
"""Build a Reddit listing JSON structure from a list of post dicts."""
|
||||
children = []
|
||||
@@ -38,7 +35,6 @@ def _make_reddit_listing(posts):
|
||||
})
|
||||
return {"data": {"children": children}}
|
||||
|
||||
|
||||
SAMPLE_LISTING = _make_reddit_listing([
|
||||
{
|
||||
"title": "Claude Code is amazing",
|
||||
@@ -72,11 +68,11 @@ def _mock_urlopen_ok(listing_data):
|
||||
resp.__exit__ = mock.MagicMock(return_value=False)
|
||||
return resp
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestSearchReturnsCorrectFields:
|
||||
"""Search query returns parsed results with correct fields."""
|
||||
|
||||
@@ -329,11 +325,11 @@ class TestMissingSubreddit:
|
||||
results = reddit_public.search("test", subreddit="nonexistent")
|
||||
assert results == []
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tests for comment enrichment (Unit 2)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestEnrichmentIntegration:
|
||||
"""search_reddit_public enriches top posts with comments."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user