Testing¶
Inkfeed uses pytest for its test suite.
Running Tests¶
Run specific tests:¶
# Run a specific test file
pytest tests/test_config.py
# Run tests matching a pattern
pytest -k "hackernews"
# Run with verbose output
pytest -v
Test Structure¶
Tests live in the tests/ directory at the root of the Inkfeed app:
Writing Tests¶
Testing Archivers¶
When testing archivers, mock HTTP responses to avoid hitting real APIs:
from unittest.mock import patch, MagicMock
from inkfeed.archiver.rss import RSSArchiver
def test_rss_archiver():
source = MagicMock()
source.url = "https://example.com/rss.xml"
source.max_articles = 5
archiver = RSSArchiver(source, Path("output"))
with patch("httpx.get") as mock_get:
mock_get.return_value.text = "<rss>...</rss>"
result = archiver.run(max_workers=1, max_retries=1)
assert len(result.groups) > 0
Testing Writers¶
Writers can be tested by providing mock ArchiveResult objects and checking the output files:
from pathlib import Path
from inkfeed.output.markdown import MarkdownWriter
def test_markdown_writer(tmp_path):
writer = MarkdownWriter(config)
writer.setup()
entries = writer.write_source(mock_result, tmp_path, "2026-02-18")
assert len(entries) > 0
# Check output files exist
assert (tmp_path / "md" / "2026-02-18").exists()
writer.teardown()
Test Coverage¶
To run with coverage reporting: