Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test failures on systems with 32-bit time_t #177

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions tests/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
ONE_DAY = 24 * ONE_HOUR
ONE_YEAR = 365.25 * ONE_DAY

hugovk marked this conversation as resolved.
Show resolved Hide resolved
with freeze_time("2020-02-02"):
FROZEN_DATE = "2010-02-02"
hugovk marked this conversation as resolved.
Show resolved Hide resolved
with freeze_time(FROZEN_DATE):
NOW = dt.datetime.now()
NOW_UTC = dt.datetime.now(tz=dt.timezone.utc)
NOW_UTC_PLUS_01_00 = dt.datetime.now(tz=dt.timezone(offset=dt.timedelta(hours=1)))
Expand Down Expand Up @@ -134,7 +135,7 @@ def test_naturaldelta(test_input: float | dt.timedelta, expected: str) -> None:
assert humanize.naturaldelta(-test_input) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"test_input, expected",
[
Expand Down Expand Up @@ -173,7 +174,7 @@ def test_naturaltime(test_input: dt.datetime, expected: str) -> None:
assert humanize.naturaltime(test_input) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"test_input, expected",
[
Expand Down Expand Up @@ -214,7 +215,7 @@ def test_naturaltime_nomonths(test_input: dt.datetime, expected: str) -> None:
assert humanize.naturaltime(test_input, months=False) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"test_args, expected",
[
Expand All @@ -234,7 +235,7 @@ def test_naturalday(test_args: list[typing.Any], expected: str) -> None:
assert humanize.naturalday(*test_args) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"test_input, expected",
[
Expand All @@ -247,31 +248,31 @@ def test_naturalday(test_args: list[typing.Any], expected: str) -> None:
("Not a date at all.", "Not a date at all."),
(VALUE_ERROR_TEST, str(VALUE_ERROR_TEST)),
(OVERFLOW_ERROR_TEST, str(OVERFLOW_ERROR_TEST)),
(dt.date(2019, 2, 2), "Feb 02 2019"),
(dt.date(2019, 3, 2), "Mar 02 2019"),
(dt.date(2019, 4, 2), "Apr 02 2019"),
(dt.date(2019, 5, 2), "May 02 2019"),
(dt.date(2019, 6, 2), "Jun 02 2019"),
(dt.date(2019, 7, 2), "Jul 02 2019"),
(dt.date(2019, 8, 2), "Aug 02 2019"),
(dt.date(2019, 9, 2), "Sep 02 2019"),
(dt.date(2019, 10, 2), "Oct 02"),
(dt.date(2019, 11, 2), "Nov 02"),
(dt.date(2019, 12, 2), "Dec 02"),
(dt.date(2020, 1, 2), "Jan 02"),
(dt.date(2020, 2, 2), "today"),
(dt.date(2020, 3, 2), "Mar 02"),
(dt.date(2020, 4, 2), "Apr 02"),
(dt.date(2020, 5, 2), "May 02"),
(dt.date(2020, 6, 2), "Jun 02"),
(dt.date(2020, 7, 2), "Jul 02"),
(dt.date(2020, 8, 2), "Aug 02 2020"),
(dt.date(2020, 9, 2), "Sep 02 2020"),
(dt.date(2020, 10, 2), "Oct 02 2020"),
(dt.date(2020, 11, 2), "Nov 02 2020"),
(dt.date(2020, 12, 2), "Dec 02 2020"),
(dt.date(2021, 1, 2), "Jan 02 2021"),
(dt.date(2021, 2, 2), "Feb 02 2021"),
(dt.date(2009, 2, 2), "Feb 02 2009"),
(dt.date(2009, 3, 2), "Mar 02 2009"),
(dt.date(2009, 4, 2), "Apr 02 2009"),
(dt.date(2009, 5, 2), "May 02 2009"),
(dt.date(2009, 6, 2), "Jun 02 2009"),
(dt.date(2009, 7, 2), "Jul 02 2009"),
(dt.date(2009, 8, 2), "Aug 02 2009"),
(dt.date(2009, 9, 2), "Sep 02 2009"),
(dt.date(2009, 10, 2), "Oct 02"),
(dt.date(2009, 11, 2), "Nov 02"),
(dt.date(2009, 12, 2), "Dec 02"),
(dt.date(2010, 1, 2), "Jan 02"),
(dt.date(2010, 2, 2), "today"),
(dt.date(2010, 3, 2), "Mar 02"),
(dt.date(2010, 4, 2), "Apr 02"),
(dt.date(2010, 5, 2), "May 02"),
(dt.date(2010, 6, 2), "Jun 02"),
(dt.date(2010, 7, 2), "Jul 02"),
(dt.date(2010, 8, 2), "Aug 02 2010"),
(dt.date(2010, 9, 2), "Sep 02 2010"),
(dt.date(2010, 10, 2), "Oct 02 2010"),
(dt.date(2010, 11, 2), "Nov 02 2010"),
(dt.date(2010, 12, 2), "Dec 02 2010"),
(dt.date(2011, 1, 2), "Jan 02 2011"),
(dt.date(2011, 2, 2), "Feb 02 2011"),
],
)
def test_naturaldate(test_input: dt.date, expected: str) -> None:
Expand Down Expand Up @@ -346,7 +347,7 @@ def test_naturaldelta_minimum_unit_explicit(
assert humanize.naturaldelta(seconds, minimum_unit=minimum_unit) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"seconds, expected",
[
Expand All @@ -369,7 +370,7 @@ def test_naturaltime_minimum_unit_default(seconds: float, expected: str) -> None
assert humanize.naturaltime(datetime) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"minimum_unit, seconds, expected",
[
Expand Down Expand Up @@ -415,7 +416,7 @@ def test_naturaltime_minimum_unit_explicit(
assert humanize.naturaltime(datetime, minimum_unit=minimum_unit) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"test_input, expected",
[
Expand Down Expand Up @@ -449,7 +450,7 @@ def test_naturaltime_timezone(test_input: dt.datetime, expected: str) -> None:
assert humanize.naturaltime(test_input) == expected


@freeze_time("2020-02-02")
@freeze_time(FROZEN_DATE)
@pytest.mark.parametrize(
"test_input, expected",
[
Expand Down
Loading