Skip to content

Commit

Permalink
Bug Repro: FakeDatetime should be real when part of ignored_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Mar 17, 2024
1 parent 12e54da commit f6b2307
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_configure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime
import sys
from unittest import mock
import freezegun
import freezegun.config
Expand Down Expand Up @@ -104,3 +106,22 @@ def test_extend_default_ignore_list_duplicate_items():
auto_tick_seconds=0,
real_asyncio=False,
)

FROZEN_DATETIME = datetime.datetime(2020, 2, 29, 0, 0, 0, tzinfo=datetime.timezone.utc)
current = datetime.datetime.now(datetime.timezone.utc)


def test_fakedatetime_is_ignored():
from . import another_module

with freezegun.freeze_time(FROZEN_DATETIME):

assert another_module.gmtime().tm_year == FROZEN_DATETIME.year
assert another_module.FakeDatetime.now().year == FROZEN_DATETIME.year

with freezegun.freeze_time(FROZEN_DATETIME, ignore=["tests.another_module"]):

assert another_module.gmtime().tm_year == current.year
assert another_module.FakeDatetime.now().year == current.year

del sys.modules["tests.another_module"]

0 comments on commit f6b2307

Please sign in to comment.