Part of lp.testing View In Hierarchy
Provides a controllable implementation of time.time().
You can either advance the time manually using advance() or have it done automatically using next_now(). The amount of seconds to advance the time by is set during initialization but can also be changed for single calls of advance() or next_now().
>>> faketime = FakeTime(1000) >>> print faketime.now() 1000 >>> print faketime.now() 1000 >>> faketime.advance(10) >>> print faketime.now() 1010 >>> print faketime.next_now() 1011 >>> print faketime.next_now(100) 1111 >>> faketime = FakeTime(1000, 5) >>> print faketime.next_now() 1005 >>> print faketime.next_now() 1010
Method | __init__ | Set up the instance. |
Method | advance | Advance the value that will be returned by now() . |
Method | now | Use this bound method instead of time.time in tests. |
Method | next_now | Read the current time and advance it. |
Parameters | start | The value that will initially be returned by now() .
If None, the current time will be used. |
advance | The value in secounds to advance the clock by by default. |