Пример #1
0
def test_datetime_patch():
    clock = TimeMachineClock()
    patcher = DatetimePatcher(clock)
    patcher.start()

    assert datetime.datetime.today() == datetime.datetime.fromtimestamp(0)

    clock.time = 3600
    assert datetime.datetime.today() == datetime.datetime.fromtimestamp(3600)
    patcher.stop()
Пример #2
0
def test_time_patch():
    clock = TimeMachineClock()
    
    patcher = TimePatcher(clock)
    patcher.start()
    
    assert time.time() == 0
    clock.time = 3600
    assert time.time() == 3600
    
    patcher.stop()
Пример #3
0
def test_sleep_patch():
    clock = TimeMachineClock()
    
    patcher = TimePatcher(clock)
    patcher.start()

    assert time.time() == 0
    time.sleep(3600)
    assert time.time() == 3600
    
    clock.time = 7200
    assert time.time() == 7200

    patcher.stop()