tests/mocktime.py
author Pulkit Goyal <pulkit@yandex-team.ru>
Fri, 05 Oct 2018 23:28:14 +0300
changeset 40078 daff528e00d7
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
py3: add 8 new passing tests to whitelist found by buildbot We are getting close! Differential Revision: https://phab.mercurial-scm.org/D4893

from __future__ import absolute_import

import os
import time

class mocktime(object):
    def __init__(self, increment):
        self.time = 0
        self.increment = [float(s) for s in increment.split()]
        self.pos = 0

    def __call__(self):
        self.time += self.increment[self.pos % len(self.increment)]
        self.pos += 1
        return self.time

def uisetup(ui):
    time.time = mocktime(os.environ.get('MOCKTIME', '0.1'))