Print a warning when datetime can't be patched #7

Closed
hannesstruss opened this Issue Dec 21, 2012 · 1 comment

Projects

None yet

2 participants

@hannesstruss

It would be very cool if a warning was printed (or even an error was raised) when the patching can't be performed properly, e.g.. because of a wrong import order.

Alternatively something like freezegun.assert_can_patch() would be handy, raising an error when datetime was imported before and can't be patched properly.

@spulec
Owner
spulec commented Jan 11, 2013

Hi Hannes. I really like the idea, but don't think there is an easy way to do this with how the code is setup. One thing you can do is

from freezegun.api import FakeDatetime
now = datetime.datetime.now()
assert isinstance(now, FakeDatetime)

If you can think of an easy way to do this, please reopen this issue because I would love to have it.

@spulec spulec closed this Jan 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment