tests/mocktime.py
author Pulkit Goyal <pulkit@yandex-team.ru>
Sat, 08 Jun 2019 19:20:31 +0300
changeset 42448 bc7b07bb36cc
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
py3: add test-contrib-emacs.t to passing tests list I installed emacs on the server running buildbot and the test started passing on Python 3. Lets add it to the list of passing test. Differential Revision: https://phab.mercurial-scm.org/D6500

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'))