Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(news): make _format_time_ago timezone test independent of local TZ (#4400)

LearningCircuitc3208eaee2cc
diff --git a/tests/news/test_api_functions.py b/tests/news/test_api_functions.py
index 88b95f3b6e..800632fad3 100644
--- a/tests/news/test_api_functions.py
+++ b/tests/news/test_api_functions.py
@@ -472,12 +472,19 @@ class TestFormatTimeAgo:
_format_time_ago("not a valid timestamp")
def test_format_time_ago_timezone_handling(self):
- """Test handling of timestamps without timezone."""
+ """Naive timestamps are interpreted as UTC by the formatter.
+
+ Build the naive string from UTC explicitly — using datetime.now()
+ (local) made this test fail on any non-UTC machine, since the
+ formatter then computed diff = (utc_now - local_now_minus_2h),
+ which collapses to ~0 on a UTC+2 box and returns "Just now".
+ """
from local_deep_research.news.api import _format_time_ago
- # Naive timestamp (no timezone)
- naive_time = datetime.now() - timedelta(hours=2)
- result = _format_time_ago(naive_time.isoformat())
+ naive_utc = (
+ datetime.now(timezone.utc) - timedelta(hours=2, seconds=1)
+ ).replace(tzinfo=None)
+ result = _format_time_ago(naive_utc.isoformat())
# The function may return "2 hours ago" or "120 minutes ago"
assert "hour" in result or "minute" in result