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

Fakedatetime.date returns a native date object #97

Closed
eternicode opened this issue Jun 11, 2015 · 4 comments
Closed

Fakedatetime.date returns a native date object #97

eternicode opened this issue Jun 11, 2015 · 4 comments

Comments

@eternicode
Copy link
Contributor

As title says, it appears the FakeDatetime.date method (see the docs) is not implemented, and so inherits from the native date object. This leads to errors like TypeError: can't compare FakeDatetime to datetime.date.

Testcase:

from unittest import TestCase
from datetime import datetime

@freeze_time(date(2015, 5, 1))
class TestDatetimeDateMethod(TestCase):
  def test_method(self):
    now = datetime.now()
    print repr(now)
    print repr(now.date())

Expected output:

FakeDatetime(2015, 5, 1, 0, 0)
FakeDate(2015, 5, 1)

Actual ouput:

FakeDatetime(2015, 5, 1, 0, 0)
datetime.date(2015, 5, 1)
@spulec spulec closed this as completed in 779eb99 Jun 14, 2015
@spulec
Copy link
Owner

spulec commented Jun 14, 2015

Thanks for opening!

Can you test now with the latest commit on master? I think it is solved.

@eternicode
Copy link
Contributor Author

Works for me! 👍

@nickpresta
Copy link

@spulec is it likely for this fix to make it into a tagged release in the near future?

EDIT: Release 0.3.3 solved my issue actually. Thanks.

@spulec
Copy link
Owner

spulec commented Jun 24, 2015

I just pushed out 0.3.4 for anyone that does need this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants