tests/mocktime.py
author Jun Wu <quark@fb.com>
Wed, 04 Oct 2017 18:50:18 -0700
changeset 34803 d817bf1fc675
parent 34316 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
run-tests: extract Popen logic to a single method This removes 3 lines in total LOC and makes the upcoming changes easier. Differential Revision: https://phab.mercurial-scm.org/D948

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