Permalink
Browse files

new works better than init since datetimes are immutable

  • Loading branch information...
1 parent 587e44f commit de73d570cd3d92f9d28e3a7125b58ad6b7cddf1e @spulec committed Jan 21, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 freezegun/api.py
View
8 freezegun/api.py
@@ -11,8 +11,8 @@ class FakeDate(real_date):
active = False
date_to_freeze = None
- def __init__(self, *args, **kwargs):
- return real_date.__init__(self, *args, **kwargs)
+ def __new__(cls, *args, **kwargs):
+ return real_date.__new__(cls, *args, **kwargs)
def __add__(self, other):
result = super(FakeDate, self).__add__(other)
@@ -43,8 +43,8 @@ class FakeDatetime(real_datetime, FakeDate):
time_to_freeze = None
tz_offset = None
- def __init__(self, *args, **kwargs):
- return real_datetime.__init__(self, *args, **kwargs)
+ def __new__(cls, *args, **kwargs):
+ return real_datetime.__new__(cls, *args, **kwargs)
def __add__(self, other):
result = super(FakeDatetime, self).__add__(other)

0 comments on commit de73d57

Please sign in to comment.