top | item 4906664

(no title)

TimothyFitz | 13 years ago

Cool, but unfortunately it breaks if the code your testing does from datetime import datetime :(

https://gist.github.com/4261936

discuss

order

spulec|13 years ago

Hey Timothy, thanks for the response. You are correct. I'll add a warning to the library and work on a solution. Unfortunately, I think it will need to involve ctypes.

subleq|13 years ago

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.