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

Bug Repro: FakeDatetime should be real when part of ignored_modules #537

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all 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
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"]
Loading