By converting date and datetime objects to isoformat and then using dateutil to convert to datetime, this freeze_time becomes exposed to more bugs in dateutil than strictly necessary. I have found when using hypothesis-datetime to test my own libraries in combination with freeze_gun that years earlier than 100 cause bugs due to dateutil interpreting them as being in the 20th or 21st centuries. This bug is avoided by simply preserving the date or datetime rather than serializing and deserializing it.
…avings is in effect. The previous implementation was dependent on `mktime` which assumes the provided timetuple is in _local_ time. The `time_to_freeze` is UTC, so `__call__` was attempting to compensate for this by using `time.timezone` to offset `time_to_freeze`. The problem is that when daylight savings is in effect, `time.timezone` is wrong by an hour and consequently `__call__` returns a timestamp which is an hour early. This issue can be addressed, and the code made much cleaner, by using simply `calendar.timegm` instead of `mktime`. `calendar.timegm` assumes the given time is in UTC so no timezone adjustment is needed and timestamp will always be correct, daylight savings or otherwise.
…t just fail gracefully with non-function callables
Special objects that overrides __eq__ which always returns True confuses the replacement. Checking for the replacement functions by identity solves this problem. Equal (==) does identity comparisions anyways unless __eq__ is overriden.
`functools.update_wrapper` and `functools.wraps` sets `__wrapped__` in Python >= 3.2, so this fix only affects Python 2.X in freezegun. The mock library uses a similar fix: https://code.google.com/p/mock/source/browse/mock.py?spec=svnd356250e275daa62b2972521885f42fa639341e6&r=e7c5f97dc1b486fbf2e7fb111ec3e6675f9d3418#65 This change allows pytest to correctly figure out the real argument names and then inject fixtures properly: https://bitbucket.org/hpk42/pytest/src/d91265465608bd3777ab0c882e5d68335d7472dd/_pytest/python.py?at=default#cl-1916
The FakeDateMeta metaclass addition made some assertions "always valid": the issubclass(obj, FakeDatetime) returns true both for fake and original datetime objects. To fix it a new set of helper functions was added. They test for exact obj.__class__ match instead.
…ess setUp doesn't break things
… info ...rather than a FakeDate. datetime.datetime.today() is effectively an alias for datetime.datetime.now(tz=None), but freezegun was returning a FakeDate object instead of a FakeDateTime.