tests/mocktime.py
author Gregory Szorc <gregory.szorc@gmail.com>
Sun, 11 Feb 2018 18:34:22 -0800
changeset 36147 6eb7d95f8970
parent 34316 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
py3: port string formatting `skipped` is a set of integer revs here. So cast integers to strings using %d. None doesn't cast to an empty string on Python 3. So use '' explicitly. Differential Revision: https://phab.mercurial-scm.org/D2146

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