tests/mocktime.py
author Boris Feld <boris.feld@octobus.net>
Tue, 17 Oct 2017 12:37:39 +0200
changeset 35263 ae79d878702b
parent 34316 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
bookmark: introduce in advance a variant of the exchange test We are about to introduce a new way to push bookmark to server. We introduce the test variant before actually updating the exchange to help the output changes to stand out when it happens.

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