tests/mocktime.py
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 11 Apr 2018 10:51:38 -0700
changeset 37613 96d735601ca1
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
wireproto: move gboptsmap to wireprototypes and rename (API) This is also shared between client and server and will need to exist in a shared module when that code is split into different modules. Differential Revision: https://phab.mercurial-scm.org/D3258

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