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()
def test_time_patch(): clock = TimeMachineClock() patcher = TimePatcher(clock) patcher.start() assert time.time() == 0 clock.time = 3600 assert time.time() == 3600 patcher.stop()
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()
def setup_method(self, method): """Start a datetime patcher.""" self.clock = TimeMachineClock() self.patcher = DatetimePatcher(clock=self.clock, event_pool=None, modules_to_patch=__name__) self.patcher.start()
def test_patcher_stop(): clock = TimeMachineClock() patcher = TimePatcher(clock) patcher.start() assert time.time() == 0 patcher.stop() assert time.time() != 0
def test_patcher_stop(): clock = TimeMachineClock() patcher = DatetimePatcher(clock) patcher.start() assert datetime.datetime.today() == datetime.datetime.fromtimestamp(0) patcher.stop() assert datetime.datetime.today() != datetime.datetime.fromtimestamp(0)