Skip to content

Commit

Permalink
Fix bug with date returing True for isinstance of datetime.
Browse files Browse the repository at this point in the history
  • Loading branch information
spulec committed Jun 21, 2013
1 parent c89a789 commit 4414d5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions freezegun/api.py
Expand Up @@ -23,7 +23,6 @@ def __instancecheck__(self, obj):


class FakeDate(with_metaclass(FakeDateMeta, real_date)):

date_to_freeze = None

def __new__(cls, *args, **kwargs):
Expand All @@ -50,7 +49,13 @@ def today(cls):
return date_to_fakedate(result)


class FakeDatetime(real_datetime, FakeDate):
class FakeDatetimeMeta(FakeDateMeta):
@classmethod
def __instancecheck__(self, obj):
return isinstance(obj, real_datetime)


class FakeDatetime(with_metaclass(FakeDatetimeMeta, real_datetime, FakeDate)):
time_to_freeze = None
tz_offset = None

Expand Down
2 changes: 2 additions & 0 deletions tests/test_class_import.py
Expand Up @@ -5,6 +5,7 @@
import datetime



@freeze_time("2012-01-14")
def test_import_datetime_works():
fake_datetime_function().day.should.equal(14)
Expand Down Expand Up @@ -40,6 +41,7 @@ def test_isinstance_works():
freezer = freeze_time('2011-01-01')
freezer.start()
isinstance(date, datetime.date).should.equal(True)
isinstance(date, datetime.datetime).should.equal(False)
isinstance(now, datetime.datetime).should.equal(True)
isinstance(now, datetime.date).should.equal(True)
freezer.stop()

0 comments on commit 4414d5e

Please sign in to comment.