From bece57029d69f6c4f73dc52d64d186047c2351dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Eustace?= Date: Sun, 19 Jun 2022 18:21:00 +0200 Subject: [PATCH] Remove obsolete test helpers --- pendulum/__init__.py | 12 +- pendulum/date.py | 5 - pendulum/datetime.py | 11 -- pendulum/helpers.py | 27 ---- pendulum/parser.py | 2 +- tests/conftest.py | 1 - tests/date/test_diff.py | 24 ++-- tests/datetime/test_comparison.py | 4 +- tests/datetime/test_diff.py | 194 ++++++++++++++--------------- tests/datetime/test_from_format.py | 6 +- tests/datetime/test_getters.py | 4 +- tests/localization/test_cs.py | 2 +- tests/localization/test_da.py | 2 +- tests/localization/test_de.py | 2 +- tests/localization/test_es.py | 2 +- tests/localization/test_fa.py | 2 +- tests/localization/test_fo.py | 2 +- tests/localization/test_fr.py | 2 +- tests/localization/test_he.py | 2 +- tests/localization/test_id.py | 2 +- tests/localization/test_it.py | 2 +- tests/localization/test_ja.py | 2 +- tests/localization/test_ko.py | 2 +- tests/localization/test_lt.py | 2 +- tests/localization/test_nb.py | 2 +- tests/localization/test_nl.py | 2 +- tests/localization/test_nn.py | 2 +- tests/localization/test_pl.py | 2 +- tests/localization/test_ru.py | 2 +- tests/localization/test_sk.py | 2 +- tests/localization/test_sv.py | 2 +- tests/test_helpers.py | 32 ----- tests/test_parsing.py | 4 +- tests/time/test_diff.py | 76 +++++------ 34 files changed, 179 insertions(+), 263 deletions(-) diff --git a/pendulum/__init__.py b/pendulum/__init__.py index d28af50b..817c27de 100644 --- a/pendulum/__init__.py +++ b/pendulum/__init__.py @@ -29,12 +29,8 @@ from pendulum.formatting import Formatter from pendulum.helpers import format_diff from pendulum.helpers import get_locale -from pendulum.helpers import get_test_now -from pendulum.helpers import has_test_now from pendulum.helpers import locale from pendulum.helpers import set_locale -from pendulum.helpers import set_test_now -from pendulum.helpers import test from pendulum.helpers import week_ends_at from pendulum.helpers import week_starts_at from pendulum.parser import parse @@ -207,6 +203,7 @@ def now(tz: str | Timezone | None = None) -> DateTime: """ Get a DateTime instance for the current date and time. """ + print(DateTime.now(tz)) return DateTime.now(tz) @@ -240,8 +237,7 @@ def from_format( """ Creates a DateTime instance from a specific format. """ - parts = _formatter.parse(string, fmt, now(), locale=locale) - + parts = _formatter.parse(string, fmt, now(tz=tz), locale=locale) if parts["tz"] is None: parts["tz"] = tz @@ -338,8 +334,6 @@ def period(start: DateTime, end: DateTime, absolute: bool = False) -> Period: "from_format", "from_timestamp", "get_locale", - "get_test_now", - "has_test_now", "instance", "local", "locale", @@ -347,8 +341,6 @@ def period(start: DateTime, end: DateTime, absolute: bool = False) -> Period: "now", "period", "set_locale", - "set_test_now", - "test", "week_ends_at", "week_starts_at", "parse", diff --git a/pendulum/date.py b/pendulum/date.py index f1303494..65dc1177 100644 --- a/pendulum/date.py +++ b/pendulum/date.py @@ -24,8 +24,6 @@ from pendulum.constants import YEARS_PER_DECADE from pendulum.exceptions import PendulumException from pendulum.helpers import add_duration -from pendulum.helpers import get_test_now -from pendulum.helpers import has_test_now from pendulum.mixins.default import FormattableMixin from pendulum.period import Period @@ -733,9 +731,6 @@ def average(self, dt: date | None = None) -> Date: @classmethod def today(cls) -> Date: - if has_test_now(): - return cast(pendulum.DateTime, get_test_now()).date() - dt = date.today() return cls(dt.year, dt.month, dt.day) diff --git a/pendulum/datetime.py b/pendulum/datetime.py index 1c6872d2..bb8b4bc8 100644 --- a/pendulum/datetime.py +++ b/pendulum/datetime.py @@ -32,8 +32,6 @@ from pendulum.date import Date from pendulum.exceptions import PendulumException from pendulum.helpers import add_duration -from pendulum.helpers import get_test_now -from pendulum.helpers import has_test_now from pendulum.period import Period from pendulum.time import Time from pendulum.tz import UTC @@ -135,15 +133,6 @@ def now( """ Get a DateTime instance for the current date and time. """ - if has_test_now(): - test_instance: DateTime = cast(DateTime, get_test_now()) - _tz = pendulum._safe_timezone(tz) - - if tz is not None and _tz != test_instance.timezone: - test_instance = test_instance.in_tz(_tz) - - return test_instance - if tz is None or tz == "local": dt = datetime.datetime.now(local_timezone()) elif tz is UTC or tz == "UTC": diff --git a/pendulum/helpers.py b/pendulum/helpers.py index f5b68f80..13b7f221 100644 --- a/pendulum/helpers.py +++ b/pendulum/helpers.py @@ -3,13 +3,11 @@ import os import struct -from contextlib import contextmanager from datetime import date from datetime import datetime from datetime import timedelta from math import copysign from typing import TYPE_CHECKING -from typing import Iterator from typing import TypeVar from typing import overload @@ -178,27 +176,6 @@ def _sign(x: float) -> int: # Global helpers -@contextmanager -def test(mock: pendulum.DateTime) -> Iterator[None]: - set_test_now(mock) - try: - yield - finally: - set_test_now() - - -def set_test_now(test_now: pendulum.DateTime | None = None) -> None: - pendulum._TEST_NOW = test_now - - -def get_test_now() -> pendulum.DateTime | None: - return pendulum._TEST_NOW - - -def has_test_now() -> bool: - return pendulum._TEST_NOW is not None - - def locale(name: str) -> Locale: return Locale.load(name) @@ -238,10 +215,6 @@ def week_ends_at(wday: int) -> None: "week_day", "add_duration", "format_diff", - "test", - "set_test_now", - "get_test_now", - "has_test_now", "locale", "set_locale", "get_locale", diff --git a/pendulum/parser.py b/pendulum/parser.py index 52d6dbd5..f78da263 100644 --- a/pendulum/parser.py +++ b/pendulum/parser.py @@ -24,7 +24,7 @@ def parse(text: str, **options: t.Any) -> Date | Time | DateTime | Duration: # Use the mock now value if it exists - options["now"] = options.get("now", pendulum.get_test_now()) + options["now"] = options.get("now") return _parse(text, **options) diff --git a/tests/conftest.py b/tests/conftest.py index 14d20b1a..9996cc3e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,7 +11,6 @@ def setup(): yield - pendulum.set_test_now() pendulum.set_locale("en") pendulum.set_local_timezone() pendulum.week_starts_at(pendulum.MONDAY) diff --git a/tests/date/test_diff.py b/tests/date/test_diff.py index 59a87ec3..56358cc8 100644 --- a/tests/date/test_diff.py +++ b/tests/date/test_diff.py @@ -129,13 +129,13 @@ def test_diff_for_humans_now_and_nearly_month(today): def test_diff_for_humans_now_and_month(): - with pendulum.test(pendulum.datetime(2016, 4, 1)): + with pendulum.travel_to(pendulum.datetime(2016, 4, 1)): today = pendulum.today().date() assert today.subtract(weeks=4).diff_for_humans() == "4 weeks ago" assert today.subtract(months=1).diff_for_humans() == "1 month ago" - with pendulum.test(pendulum.datetime(2017, 3, 1)): + with pendulum.travel_to(pendulum.datetime(2017, 3, 1)): today = pendulum.today().date() assert today.subtract(weeks=4).diff_for_humans() == "1 month ago" @@ -182,23 +182,23 @@ def test_diff_for_humans_now_and_nearly_future_month(today): def test_diff_for_humans_now_and_future_month(): - with pendulum.test(pendulum.datetime(2016, 3, 1)): + with pendulum.travel_to(pendulum.datetime(2016, 3, 1)): today = pendulum.today("UTC").date() assert today.add(weeks=4).diff_for_humans() == "in 4 weeks" assert today.add(months=1).diff_for_humans() == "in 1 month" - with pendulum.test(pendulum.datetime(2017, 3, 31)): + with pendulum.travel_to(pendulum.datetime(2017, 3, 31)): today = pendulum.today("UTC").date() assert today.add(months=1).diff_for_humans() == "in 1 month" - with pendulum.test(pendulum.datetime(2017, 4, 30)): + with pendulum.travel_to(pendulum.datetime(2017, 4, 30)): today = pendulum.today("UTC").date() assert today.add(months=1).diff_for_humans() == "in 1 month" - with pendulum.test(pendulum.datetime(2017, 1, 31)): + with pendulum.travel_to(pendulum.datetime(2017, 1, 31)): today = pendulum.today("UTC").date() assert today.add(weeks=4).diff_for_humans() == "in 1 month" @@ -245,23 +245,23 @@ def test_diff_for_humans_other_and_nearly_month(today): def test_diff_for_humans_other_and_month(): - with pendulum.test(pendulum.datetime(2016, 3, 1)): + with pendulum.travel_to(pendulum.datetime(2016, 3, 1)): today = pendulum.today().date() assert today.diff_for_humans(today.add(weeks=4)) == "4 weeks before" assert today.diff_for_humans(today.add(months=1)) == "1 month before" - with pendulum.test(pendulum.datetime(2017, 3, 31)): + with pendulum.travel_to(pendulum.datetime(2017, 3, 31)): today = pendulum.today().date() assert today.diff_for_humans(today.add(months=1)) == "1 month before" - with pendulum.test(pendulum.datetime(2017, 4, 30)): + with pendulum.travel_to(pendulum.datetime(2017, 4, 30)): today = pendulum.today().date() assert today.diff_for_humans(today.add(months=1)) == "1 month before" - with pendulum.test(pendulum.datetime(2017, 1, 31)): + with pendulum.travel_to(pendulum.datetime(2017, 1, 31)): today = pendulum.today().date() assert today.diff_for_humans(today.add(weeks=4)) == "1 month before" @@ -308,13 +308,13 @@ def test_diff_for_humans_other_and_nearly_future_month(today): def test_diff_for_humans_other_and_future_month(): - with pendulum.test(pendulum.datetime(2016, 3, 1)): + with pendulum.travel_to(pendulum.datetime(2016, 3, 1)): today = pendulum.today().date() assert today.diff_for_humans(today.subtract(weeks=4)) == "4 weeks after" assert today.diff_for_humans(today.subtract(months=1)) == "1 month after" - with pendulum.test(pendulum.datetime(2017, 2, 28)): + with pendulum.travel_to(pendulum.datetime(2017, 2, 28)): today = pendulum.today().date() assert today.diff_for_humans(today.subtract(weeks=4)) == "1 month after" diff --git a/tests/datetime/test_comparison.py b/tests/datetime/test_comparison.py index af57cecb..ad81e739 100644 --- a/tests/datetime/test_comparison.py +++ b/tests/datetime/test_comparison.py @@ -241,7 +241,7 @@ def test_less_than_or_equal_with_timezone_false(): def test_is_anniversary(): - with pendulum.test(pendulum.now()): + with pendulum.travel_to(pendulum.now()): d = pendulum.now() an_anniversary = d.subtract(years=1) assert an_anniversary.is_anniversary() @@ -258,7 +258,7 @@ def test_is_anniversary(): def test_is_birthday(): # backward compatibility - with pendulum.test(pendulum.now()): + with pendulum.travel_to(pendulum.now()): d = pendulum.now() an_anniversary = d.subtract(years=1) assert an_anniversary.is_birthday() diff --git a/tests/datetime/test_diff.py b/tests/datetime/test_diff.py index 57d88012..7a315070 100644 --- a/tests/datetime/test_diff.py +++ b/tests/datetime/test_diff.py @@ -23,7 +23,7 @@ def test_diff_in_years_negative_no_sign(): def test_diff_in_years_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(years=1).diff().in_years() == 1 @@ -48,7 +48,7 @@ def test_diff_in_months_negative_no_sign(): def test_diff_in_months_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(years=1).diff().in_months() == 12 @@ -73,7 +73,7 @@ def test_diff_in_days_negative_no_sign(): def test_diff_in_days_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(weeks=1).diff().in_days() == 7 @@ -98,7 +98,7 @@ def test_diff_in_weeks_negative_no_sign(): def test_diff_in_weeks_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(weeks=1).diff().in_weeks() == 1 @@ -123,7 +123,7 @@ def test_diff_in_hours_negative_no_sign(): def test_diff_in_hours_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 15)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 15), freeze=True): assert pendulum.now().subtract(days=2).diff().in_hours() == 48 @@ -153,7 +153,7 @@ def test_diff_in_minutes_negative_no_sign(): def test_diff_in_minutes_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(hours=1).diff().in_minutes() == 60 @@ -183,7 +183,7 @@ def test_diff_in_seconds_negative_no_sign(): def test_diff_in_seconds_vs_default_now(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(hours=1).diff().in_seconds() == 3600 @@ -199,7 +199,7 @@ def test_diff_in_seconds_with_timezones(): def test_diff_for_humans_now_and_second(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().diff_for_humans() == "a few seconds ago" @@ -207,211 +207,211 @@ def test_diff_for_humans_now_and_second_with_timezone(): van_now = pendulum.now("America/Vancouver") here_now = van_now.in_timezone(pendulum.now().timezone) - with pendulum.test(here_now): + with pendulum.travel_to(here_now, freeze=True): assert here_now.diff_for_humans() == "a few seconds ago" def test_diff_for_humans_now_and_seconds(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().subtract(seconds=2).diff_for_humans() == "a few seconds ago" ) def test_diff_for_humans_now_and_nearly_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(seconds=59).diff_for_humans() == "59 seconds ago" def test_diff_for_humans_now_and_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(minutes=1).diff_for_humans() == "1 minute ago" def test_diff_for_humans_now_and_minutes(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(minutes=2).diff_for_humans() == "2 minutes ago" def test_diff_for_humans_now_and_nearly_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(minutes=59).diff_for_humans() == "59 minutes ago" def test_diff_for_humans_now_and_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(hours=1).diff_for_humans() == "1 hour ago" def test_diff_for_humans_now_and_hours(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(hours=2).diff_for_humans() == "2 hours ago" def test_diff_for_humans_now_and_nearly_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(hours=23).diff_for_humans() == "23 hours ago" def test_diff_for_humans_now_and_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(days=1).diff_for_humans() == "1 day ago" def test_diff_for_humans_now_and_days(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(days=2).diff_for_humans() == "2 days ago" def test_diff_for_humans_now_and_nearly_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(days=6).diff_for_humans() == "6 days ago" def test_diff_for_humans_now_and_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(weeks=1).diff_for_humans() == "1 week ago" def test_diff_for_humans_now_and_weeks(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(weeks=2).diff_for_humans() == "2 weeks ago" def test_diff_for_humans_now_and_nearly_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(weeks=3).diff_for_humans() == "3 weeks ago" def test_diff_for_humans_now_and_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(weeks=4).diff_for_humans() == "4 weeks ago" assert pendulum.now().subtract(months=1).diff_for_humans() == "1 month ago" def test_diff_for_humans_now_and_months(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(months=2).diff_for_humans() == "2 months ago" def test_diff_for_humans_now_and_nearly_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(months=11).diff_for_humans() == "11 months ago" def test_diff_for_humans_now_and_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(years=1).diff_for_humans() == "1 year ago" def test_diff_for_humans_now_and_years(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().subtract(years=2).diff_for_humans() == "2 years ago" def test_diff_for_humans_now_and_future_second(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(seconds=1).diff_for_humans() == "in a few seconds" def test_diff_for_humans_now_and_future_seconds(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(seconds=2).diff_for_humans() == "in a few seconds" def test_diff_for_humans_now_and_nearly_future_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(seconds=59).diff_for_humans() == "in 59 seconds" def test_diff_for_humans_now_and_future_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(minutes=1).diff_for_humans() == "in 1 minute" def test_diff_for_humans_now_and_future_minutes(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(minutes=2).diff_for_humans() == "in 2 minutes" def test_diff_for_humans_now_and_nearly_future_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(minutes=59).diff_for_humans() == "in 59 minutes" def test_diff_for_humans_now_and_future_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(hours=1).diff_for_humans() == "in 1 hour" def test_diff_for_humans_now_and_future_hours(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(hours=2).diff_for_humans() == "in 2 hours" def test_diff_for_humans_now_and_nearly_future_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(hours=23).diff_for_humans() == "in 23 hours" def test_diff_for_humans_now_and_future_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(days=1).diff_for_humans() == "in 1 day" def test_diff_for_humans_now_and_future_days(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(days=2).diff_for_humans() == "in 2 days" def test_diff_for_humans_now_and_nearly_future_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(days=6).diff_for_humans() == "in 6 days" def test_diff_for_humans_now_and_future_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(weeks=1).diff_for_humans() == "in 1 week" def test_diff_for_humans_now_and_future_weeks(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(weeks=2).diff_for_humans() == "in 2 weeks" def test_diff_for_humans_now_and_nearly_future_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(weeks=3).diff_for_humans() == "in 3 weeks" def test_diff_for_humans_now_and_future_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(weeks=4).diff_for_humans() == "in 4 weeks" assert pendulum.now().add(months=1).diff_for_humans() == "in 1 month" def test_diff_for_humans_now_and_future_months(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(months=2).diff_for_humans() == "in 2 months" def test_diff_for_humans_now_and_nearly_future_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(months=11).diff_for_humans() == "in 11 months" def test_diff_for_humans_now_and_future_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(years=1).diff_for_humans() == "in 1 year" def test_diff_for_humans_now_and_future_years(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert pendulum.now().add(years=2).diff_for_humans() == "in 2 years" def test_diff_for_humans_other_and_second(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(seconds=1)) == "a few seconds before" @@ -419,7 +419,7 @@ def test_diff_for_humans_other_and_second(): def test_diff_for_humans_other_and_seconds(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(seconds=2)) == "a few seconds before" @@ -427,7 +427,7 @@ def test_diff_for_humans_other_and_seconds(): def test_diff_for_humans_other_and_nearly_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(seconds=59)) == "59 seconds before" @@ -435,7 +435,7 @@ def test_diff_for_humans_other_and_nearly_minute(): def test_diff_for_humans_other_and_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(minutes=1)) == "1 minute before" @@ -443,7 +443,7 @@ def test_diff_for_humans_other_and_minute(): def test_diff_for_humans_other_and_minutes(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(minutes=2)) == "2 minutes before" @@ -451,7 +451,7 @@ def test_diff_for_humans_other_and_minutes(): def test_diff_for_humans_other_and_nearly_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(minutes=59)) == "59 minutes before" @@ -459,7 +459,7 @@ def test_diff_for_humans_other_and_nearly_hour(): def test_diff_for_humans_other_and_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(hours=1)) == "1 hour before" @@ -467,7 +467,7 @@ def test_diff_for_humans_other_and_hour(): def test_diff_for_humans_other_and_hours(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(hours=2)) == "2 hours before" @@ -475,7 +475,7 @@ def test_diff_for_humans_other_and_hours(): def test_diff_for_humans_other_and_nearly_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(hours=23)) == "23 hours before" @@ -483,14 +483,14 @@ def test_diff_for_humans_other_and_nearly_day(): def test_diff_for_humans_other_and_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(days=1)) == "1 day before" ) def test_diff_for_humans_other_and_days(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(days=2)) == "2 days before" @@ -498,7 +498,7 @@ def test_diff_for_humans_other_and_days(): def test_diff_for_humans_other_and_nearly_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(days=6)) == "6 days before" @@ -506,7 +506,7 @@ def test_diff_for_humans_other_and_nearly_week(): def test_diff_for_humans_other_and_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(weeks=1)) == "1 week before" @@ -514,7 +514,7 @@ def test_diff_for_humans_other_and_week(): def test_diff_for_humans_other_and_weeks(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(weeks=2)) == "2 weeks before" @@ -522,7 +522,7 @@ def test_diff_for_humans_other_and_weeks(): def test_diff_for_humans_other_and_nearly_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(weeks=3)) == "3 weeks before" @@ -530,7 +530,7 @@ def test_diff_for_humans_other_and_nearly_month(): def test_diff_for_humans_other_and_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(weeks=4)) == "4 weeks before" @@ -542,7 +542,7 @@ def test_diff_for_humans_other_and_month(): def test_diff_for_humans_other_and_months(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(months=2)) == "2 months before" @@ -550,7 +550,7 @@ def test_diff_for_humans_other_and_months(): def test_diff_for_humans_other_and_nearly_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(months=11)) == "11 months before" @@ -558,7 +558,7 @@ def test_diff_for_humans_other_and_nearly_year(): def test_diff_for_humans_other_and_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(years=1)) == "1 year before" @@ -566,7 +566,7 @@ def test_diff_for_humans_other_and_year(): def test_diff_for_humans_other_and_years(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().add(years=2)) == "2 years before" @@ -574,7 +574,7 @@ def test_diff_for_humans_other_and_years(): def test_diff_for_humans_other_and_future_second(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(seconds=1)) == "a few seconds after" @@ -582,7 +582,7 @@ def test_diff_for_humans_other_and_future_second(): def test_diff_for_humans_other_and_future_seconds(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(seconds=2)) == "a few seconds after" @@ -590,7 +590,7 @@ def test_diff_for_humans_other_and_future_seconds(): def test_diff_for_humans_other_and_nearly_future_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(seconds=59)) == "59 seconds after" @@ -598,7 +598,7 @@ def test_diff_for_humans_other_and_nearly_future_minute(): def test_diff_for_humans_other_and_future_minute(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(minutes=1)) == "1 minute after" @@ -606,7 +606,7 @@ def test_diff_for_humans_other_and_future_minute(): def test_diff_for_humans_other_and_future_minutes(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(minutes=2)) == "2 minutes after" @@ -614,7 +614,7 @@ def test_diff_for_humans_other_and_future_minutes(): def test_diff_for_humans_other_and_nearly_future_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(minutes=59)) == "59 minutes after" @@ -622,7 +622,7 @@ def test_diff_for_humans_other_and_nearly_future_hour(): def test_diff_for_humans_other_and_future_hour(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(hours=1)) == "1 hour after" @@ -630,7 +630,7 @@ def test_diff_for_humans_other_and_future_hour(): def test_diff_for_humans_other_and_future_hours(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(hours=2)) == "2 hours after" @@ -638,7 +638,7 @@ def test_diff_for_humans_other_and_future_hours(): def test_diff_for_humans_other_and_nearly_future_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(hours=23)) == "23 hours after" @@ -646,7 +646,7 @@ def test_diff_for_humans_other_and_nearly_future_day(): def test_diff_for_humans_other_and_future_day(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(days=1)) == "1 day after" @@ -654,7 +654,7 @@ def test_diff_for_humans_other_and_future_day(): def test_diff_for_humans_other_and_future_days(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(days=2)) == "2 days after" @@ -662,7 +662,7 @@ def test_diff_for_humans_other_and_future_days(): def test_diff_for_humans_other_and_nearly_future_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(days=6)) == "6 days after" @@ -670,7 +670,7 @@ def test_diff_for_humans_other_and_nearly_future_week(): def test_diff_for_humans_other_and_future_week(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(weeks=1)) == "1 week after" @@ -678,7 +678,7 @@ def test_diff_for_humans_other_and_future_week(): def test_diff_for_humans_other_and_future_weeks(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(weeks=2)) == "2 weeks after" @@ -686,7 +686,7 @@ def test_diff_for_humans_other_and_future_weeks(): def test_diff_for_humans_other_and_nearly_future_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(weeks=3)) == "3 weeks after" @@ -694,7 +694,7 @@ def test_diff_for_humans_other_and_nearly_future_month(): def test_diff_for_humans_other_and_future_month(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(weeks=4)) == "4 weeks after" @@ -706,7 +706,7 @@ def test_diff_for_humans_other_and_future_month(): def test_diff_for_humans_other_and_future_months(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(months=2)) == "2 months after" @@ -714,7 +714,7 @@ def test_diff_for_humans_other_and_future_months(): def test_diff_for_humans_other_and_nearly_future_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(months=11)) == "11 months after" @@ -722,7 +722,7 @@ def test_diff_for_humans_other_and_nearly_future_year(): def test_diff_for_humans_other_and_future_year(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(years=1)) == "1 year after" @@ -730,7 +730,7 @@ def test_diff_for_humans_other_and_future_year(): def test_diff_for_humans_other_and_future_years(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(years=2)) == "2 years after" @@ -738,7 +738,7 @@ def test_diff_for_humans_other_and_future_years(): def test_diff_for_humans_absolute_seconds(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(seconds=59), True) == "59 seconds" @@ -750,7 +750,7 @@ def test_diff_for_humans_absolute_seconds(): def test_diff_for_humans_absolute_minutes(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(minutes=30), True) == "30 minutes" @@ -762,7 +762,7 @@ def test_diff_for_humans_absolute_minutes(): def test_diff_for_humans_absolute_hours(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(hours=3), True) == "3 hours" @@ -774,7 +774,7 @@ def test_diff_for_humans_absolute_hours(): def test_diff_for_humans_absolute_days(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(days=2), True) == "2 days" @@ -785,7 +785,7 @@ def test_diff_for_humans_absolute_days(): def test_diff_for_humans_absolute_weeks(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(weeks=2), True) == "2 weeks" @@ -797,7 +797,7 @@ def test_diff_for_humans_absolute_weeks(): def test_diff_for_humans_absolute_months(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(months=2), True) == "2 months" @@ -809,7 +809,7 @@ def test_diff_for_humans_absolute_months(): def test_diff_for_humans_absolute_years(): - with pendulum.test(pendulum.datetime(2012, 1, 1, 1, 2, 3)): + with pendulum.travel_to(pendulum.datetime(2012, 1, 1, 1, 2, 3), freeze=True): assert ( pendulum.now().diff_for_humans(pendulum.now().subtract(years=1), True) == "1 year" @@ -823,7 +823,7 @@ def test_diff_for_humans_absolute_years(): def test_diff_for_humans_accuracy(): now = pendulum.now("utc") - with pendulum.test(now.add(microseconds=200)): + with pendulum.travel_to(now.add(microseconds=200), freeze=True): assert now.add(years=1).diff_for_humans(absolute=True) == "1 year" assert now.add(months=11).diff_for_humans(absolute=True) == "11 months" assert now.add(days=27).diff_for_humans(absolute=True) == "4 weeks" @@ -832,7 +832,7 @@ def test_diff_for_humans_accuracy(): # DST now = pendulum.datetime(2017, 3, 7, tz="America/Toronto") - with pendulum.test(now): + with pendulum.travel_to(now, freeze=True): assert now.add(days=6).diff_for_humans(absolute=True) == "6 days" diff --git a/tests/datetime/test_from_format.py b/tests/datetime/test_from_format.py index 9420a0d1..10c4a233 100644 --- a/tests/datetime/test_from_format.py +++ b/tests/datetime/test_from_format.py @@ -155,7 +155,7 @@ def test_from_format(text, fmt, expected, now): else: now = pendulum.parse(now) - with pendulum.test(now): + with pendulum.travel_to(now, freeze=True): assert pendulum.from_format(text, fmt).isoformat() == expected @@ -172,7 +172,7 @@ def test_from_format(text, fmt, expected, now): def test_from_format_with_locale(text, fmt, expected): now = pendulum.datetime(2018, 2, 2) - with pendulum.test(now): + with pendulum.travel_to(now, freeze=True): formatted = pendulum.from_format(text, fmt, locale="fr").isoformat() assert formatted == expected @@ -192,7 +192,7 @@ def test_from_format_with_locale(text, fmt, expected): def test_from_format_error(text, fmt, locale): now = pendulum.datetime(2018, 2, 2) - with pendulum.test(now), pytest.raises(ValueError): + with pendulum.travel_to(now, freeze=True), pytest.raises(ValueError): pendulum.from_format(text, fmt, locale=locale) diff --git a/tests/datetime/test_getters.py b/tests/datetime/test_getters.py index 97aa9a37..50746234 100644 --- a/tests/datetime/test_getters.py +++ b/tests/datetime/test_getters.py @@ -219,7 +219,7 @@ def test_timezone_name(): def test_is_future(): - with pendulum.test(DateTime(2000, 1, 1)): + with pendulum.travel_to(DateTime(2000, 1, 1)): d = pendulum.now() assert not d.is_future() d = d.add(days=1) @@ -227,7 +227,7 @@ def test_is_future(): def test_is_past(): - with pendulum.test(DateTime(2000, 1, 1)): + with pendulum.travel_to(DateTime(2000, 1, 1), freeze=True): d = pendulum.now() assert not d.is_past() d = d.subtract(days=1) diff --git a/tests/localization/test_cs.py b/tests/localization/test_cs.py index b938e63c..71b8340f 100644 --- a/tests/localization/test_cs.py +++ b/tests/localization/test_cs.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_da.py b/tests/localization/test_da.py index ef46a083..b08adfee 100644 --- a/tests/localization/test_da.py +++ b/tests/localization/test_da.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_de.py b/tests/localization/test_de.py index 45f544a7..9c72b792 100644 --- a/tests/localization/test_de.py +++ b/tests/localization/test_de.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_es.py b/tests/localization/test_es.py index 7fb8d632..747ec6f4 100644 --- a/tests/localization/test_es.py +++ b/tests/localization/test_es.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_fa.py b/tests/localization/test_fa.py index 3fb9124f..39d2e4ae 100644 --- a/tests/localization/test_fa.py +++ b/tests/localization/test_fa.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_fo.py b/tests/localization/test_fo.py index af0bd354..f451553e 100644 --- a/tests/localization/test_fo.py +++ b/tests/localization/test_fo.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_fr.py b/tests/localization/test_fr.py index 6df0d656..1cfef5b5 100644 --- a/tests/localization/test_fr.py +++ b/tests/localization/test_fr.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_he.py b/tests/localization/test_he.py index f6b96c4a..6186ef21 100644 --- a/tests/localization/test_he.py +++ b/tests/localization/test_he.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_id.py b/tests/localization/test_id.py index a34c10a5..3dd316ca 100644 --- a/tests/localization/test_id.py +++ b/tests/localization/test_id.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_it.py b/tests/localization/test_it.py index 1c5c4192..1918a2bd 100644 --- a/tests/localization/test_it.py +++ b/tests/localization/test_it.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_ja.py b/tests/localization/test_ja.py index 920d3c56..82457fd9 100644 --- a/tests/localization/test_ja.py +++ b/tests/localization/test_ja.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_ko.py b/tests/localization/test_ko.py index 79add872..e33ca25d 100644 --- a/tests/localization/test_ko.py +++ b/tests/localization/test_ko.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_lt.py b/tests/localization/test_lt.py index 5dcdc387..71de1ac0 100644 --- a/tests/localization/test_lt.py +++ b/tests/localization/test_lt.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_nb.py b/tests/localization/test_nb.py index be12df2f..3f696e5c 100644 --- a/tests/localization/test_nb.py +++ b/tests/localization/test_nb.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_nl.py b/tests/localization/test_nl.py index b4857319..68227eca 100644 --- a/tests/localization/test_nl.py +++ b/tests/localization/test_nl.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_nn.py b/tests/localization/test_nn.py index 4c72644a..d4b8099c 100644 --- a/tests/localization/test_nn.py +++ b/tests/localization/test_nn.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_pl.py b/tests/localization/test_pl.py index 81c8ff26..2b6e707d 100644 --- a/tests/localization/test_pl.py +++ b/tests/localization/test_pl.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_ru.py b/tests/localization/test_ru.py index c4fbcd7b..be0e645c 100644 --- a/tests/localization/test_ru.py +++ b/tests/localization/test_ru.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_sk.py b/tests/localization/test_sk.py index 1b47a379..5553e7f9 100644 --- a/tests/localization/test_sk.py +++ b/tests/localization/test_sk.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/localization/test_sv.py b/tests/localization/test_sv.py index 7d93a06b..e0e4e65e 100644 --- a/tests/localization/test_sv.py +++ b/tests/localization/test_sv.py @@ -6,7 +6,7 @@ def test_diff_for_humans(): - with pendulum.test(pendulum.datetime(2016, 8, 29)): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): diff_for_humans() diff --git a/tests/test_helpers.py b/tests/test_helpers.py index c1bbbdf2..e3daeac5 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -11,7 +11,6 @@ from pendulum.helpers import days_in_year from pendulum.helpers import precise_diff from pendulum.helpers import week_day -from tests.conftest import assert_datetime def assert_diff( @@ -124,21 +123,6 @@ def test_days_in_years(): assert days_in_year(2016) == 366 -def test_test_now(): - now = pendulum.datetime(2000, 11, 10, 12, 34, 56, 123456) - pendulum.set_test_now(now) - - assert pendulum.has_test_now() - assert now == pendulum.get_test_now() - - assert_datetime(pendulum.now(), 2000, 11, 10, 12, 34, 56, 123456) - - pendulum.set_test_now() - - assert not pendulum.has_test_now() - assert pendulum.get_test_now() is None - - def test_locale(): dt = pendulum.datetime(2000, 11, 10, 12, 34, 56, 123456) pendulum.set_locale("fr") @@ -193,19 +177,3 @@ def test_week_ends_at_invalid_value(): with pytest.raises(ValueError): pendulum.week_ends_at(11) - - -def test_with_test(): - t = pendulum.datetime(2000, 1, 1) - - with pendulum.test(t): - assert pendulum.now() == t - - assert pendulum.now() != t - - # Also make sure that it restores things after an exception - with pytest.raises(RuntimeError), pendulum.test(t): - assert pendulum.now() == t - raise RuntimeError - - assert pendulum.now() != t diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 1edbcede..8890e23f 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -26,7 +26,7 @@ def test_parse(): assert_datetime(dt, 2016, 10, 16, 0, 0, 0, 0) assert dt.offset == 0 - with pendulum.test(pendulum.datetime(2015, 11, 12)): + with pendulum.travel_to(pendulum.datetime(2015, 11, 12), freeze=True): text = "12:34:56.123456" dt = pendulum.parse(text) @@ -131,7 +131,7 @@ def test_parse_now(): mock_now = pendulum.yesterday() - with pendulum.test(mock_now): + with pendulum.travel_to(mock_now, freeze=True): assert pendulum.parse("now") == mock_now diff --git a/tests/time/test_diff.py b/tests/time/test_diff.py index dd5e0938..629a0580 100644 --- a/tests/time/test_diff.py +++ b/tests/time/test_diff.py @@ -21,7 +21,7 @@ def test_diff_in_hours_negative_no_sign(): def test_diff_in_hours_vs_default_now(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(hours=2).diff().in_hours() == 2 @@ -53,7 +53,7 @@ def test_diff_in_minutes_negative_no_sign(): def test_diff_in_minutes_vs_default_now(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(hours=1).diff().in_minutes() == 60 @@ -85,7 +85,7 @@ def test_diff_in_seconds_negative_no_sign(): def test_diff_in_seconds_vs_default_now(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(hours=1).diff().in_seconds() == 3600 @@ -97,231 +97,231 @@ def test_diff_in_seconds_ensure_is_truncated(): def test_diff_for_humans_now_and_second(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans() == "a few seconds ago" def test_diff_for_humans_now_and_seconds(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(seconds=2).diff_for_humans() == "a few seconds ago" def test_diff_for_humans_now_and_nearly_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(seconds=59).diff_for_humans() == "59 seconds ago" def test_diff_for_humans_now_and_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(minutes=1).diff_for_humans() == "1 minute ago" def test_diff_for_humans_now_and_minutes(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(minutes=2).diff_for_humans() == "2 minutes ago" def test_diff_for_humans_now_and_nearly_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(minutes=59).diff_for_humans() == "59 minutes ago" def test_diff_for_humans_now_and_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(hours=1).diff_for_humans() == "1 hour ago" def test_diff_for_humans_now_and_hours(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.subtract(hours=2).diff_for_humans() == "2 hours ago" def test_diff_for_humans_now_and_future_second(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(seconds=1).diff_for_humans() == "in a few seconds" def test_diff_for_humans_now_and_future_seconds(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(seconds=2).diff_for_humans() == "in a few seconds" def test_diff_for_humans_now_and_nearly_future_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(seconds=59).diff_for_humans() == "in 59 seconds" def test_diff_for_humans_now_and_future_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(minutes=1).diff_for_humans() == "in 1 minute" def test_diff_for_humans_now_and_future_minutes(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(minutes=2).diff_for_humans() == "in 2 minutes" def test_diff_for_humans_now_and_nearly_future_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(minutes=59).diff_for_humans() == "in 59 minutes" def test_diff_for_humans_now_and_future_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(hours=1).diff_for_humans() == "in 1 hour" def test_diff_for_humans_now_and_future_hours(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.add(hours=2).diff_for_humans() == "in 2 hours" def test_diff_for_humans_other_and_second(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(seconds=1)) == "a few seconds before" def test_diff_for_humans_other_and_seconds(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(seconds=2)) == "a few seconds before" def test_diff_for_humans_other_and_nearly_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(seconds=59)) == "59 seconds before" def test_diff_for_humans_other_and_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(minutes=1)) == "1 minute before" def test_diff_for_humans_other_and_minutes(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(minutes=2)) == "2 minutes before" def test_diff_for_humans_other_and_nearly_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(minutes=59)) == "59 minutes before" def test_diff_for_humans_other_and_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(hours=1)) == "1 hour before" def test_diff_for_humans_other_and_hours(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.add(hours=2)) == "2 hours before" def test_diff_for_humans_other_and_future_second(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(seconds=1)) == "a few seconds after" def test_diff_for_humans_other_and_future_seconds(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(seconds=2)) == "a few seconds after" def test_diff_for_humans_other_and_nearly_future_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(seconds=59)) == "59 seconds after" def test_diff_for_humans_other_and_future_minute(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(minutes=1)) == "1 minute after" def test_diff_for_humans_other_and_future_minutes(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(minutes=2)) == "2 minutes after" def test_diff_for_humans_other_and_nearly_future_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(minutes=59)) == "59 minutes after" def test_diff_for_humans_other_and_future_hour(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(hours=1)) == "1 hour after" def test_diff_for_humans_other_and_future_hours(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(hours=2)) == "2 hours after" def test_diff_for_humans_absolute_seconds(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(seconds=59), True) == "59 seconds" @@ -331,7 +331,7 @@ def test_diff_for_humans_absolute_seconds(): def test_diff_for_humans_absolute_minutes(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(minutes=30), True) == "30 minutes" @@ -341,7 +341,7 @@ def test_diff_for_humans_absolute_minutes(): def test_diff_for_humans_absolute_hours(): - with pendulum.test(pendulum.today().at(12, 34, 56)): + with pendulum.travel_to(pendulum.today().at(12, 34, 56)): now = pendulum.now().time() assert now.diff_for_humans(now.subtract(hours=3), True) == "3 hours"