tests/mocktime.py
author Pulkit Goyal <7895pulkit@gmail.com>
Wed, 30 Dec 2020 14:56:34 +0530
changeset 46206 9540945e51fd
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
actions: rename DEFICIENCY constant to FORMAT_VARIANT It was not obvious what does deficieny means and every format change can't be a deficiency. There are some format changes like compression levels, share-safe which can't be understood at deficiencies. This patch renames the constant to make things clearer. Differential Revision: https://phab.mercurial-scm.org/D9664

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