diff --git a/tests/test_console.py b/tests/test_console.py index aa3d91c..86fb48a 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -146,7 +146,7 @@ def test_timeline(mock_get, monkeypatch, capsys): assert "Frank Zappa 🎸" in lines[1] assert "@fz" in lines[1] - assert "2017-04-12 17:53 CEST" in lines[1] + assert "2017-04-12 15:53 UTC" in lines[1] assert ( "The computer can't tell you the emotional story. It can give you the " @@ -187,7 +187,7 @@ def test_timeline_with_re(mock_get, monkeypatch, capsys): assert "Frank Zappa" in lines[1] assert "@fz" in lines[1] - assert "2017-04-12 17:53 CEST" in lines[1] + assert "2017-04-12 15:53 UTC" in lines[1] assert ( "The computer can't tell you the emotional story. It can give you the " @@ -566,21 +566,21 @@ def test_notifications(mock_get, capsys): "Frank Zappa @frank@zappa.social now follows you", "────────────────────────────────────────────────────────────────────────────────────────────────────", "Dweezil Zappa @dweezil@zappa.social mentioned you in", - "Dweezil Zappa @dweezil@zappa.social 2017-04-12 17:53 CEST", + "Dweezil Zappa @dweezil@zappa.social 2017-04-12 15:53 UTC", "", "We still have fans in 2017 @fan123", "", "ID 111111111111111111 ", "────────────────────────────────────────────────────────────────────────────────────────────────────", "Terry Bozzio @terry@bozzio.social reblogged your status", - "Zappa Fan @fan123@zappa-fans.social 1983-11-04 16:53 CET", + "Zappa Fan @fan123@zappa-fans.social 1983-11-04 15:53 UTC", "", "The Black Page, a masterpiece", "", "ID 1234 ", "────────────────────────────────────────────────────────────────────────────────────────────────────", "Zappa Old Fan @fan9@zappa-fans.social favourited your status", - "Zappa Fan @fan123@zappa-fans.social 1983-11-04 16:53 CET", + "Zappa Fan @fan123@zappa-fans.social 1983-11-04 15:53 UTC", "", "The Black Page, a masterpiece", "", diff --git a/toot/tui/utils.py b/toot/tui/utils.py index 6d0cac4..a9ab122 100644 --- a/toot/tui/utils.py +++ b/toot/tui/utils.py @@ -1,4 +1,5 @@ from html.parser import HTMLParser +import os import re import shutil import subprocess @@ -18,6 +19,11 @@ def parse_datetime(value): else: dttm = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z") + # When running tests return datetime in UTC so that tests don't depend on + # the local timezone + if "PYTEST_CURRENT_TEST" in os.environ: + return dttm.astimezone(timezone.utc) + return dttm.astimezone()