tests/mocktime.py
author Sushil khanchi <sushilkhanchi97@gmail.com>
Thu, 27 Aug 2020 12:24:57 +0530
changeset 45406 fa1a5527f642
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
tests: add a --retest test to demonstrate a fix in next patch As you see above the added lines, there was only one test failed. So the output should be: "running 1 tests using 1 parallel processes" Next patch will be fixing this. Differential Revision: https://phab.mercurial-scm.org/D8964

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