Hacker News new | past | comments | ask | show | jobs | submit login

Have you tried patching the now() method onto datetime.datetime instead of replacing the whole class? If that doesn't work, you could replace datetime first:

    import freezegun; freezegun.monkey_patch()
    from datetime import datetime
After that, freeze_time would just set a flag on your datetime class.



Sadly, it's not possible. datetime is a C class, so it is immutable.


Correct. I've gone with his latter solution for now and added a warning about import order. I'm not very happy with this solution through and will be spending some time with ctypes in the next few days to come up with something better.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: