tests/mocktime.py
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 09 Sep 2022 12:45:26 -0700
changeset 49495 59a72267f5ce
parent 48946 642e31cb55f0
permissions -rw-r--r--
fsmonitor: migrate Python ABCs from collections to collections.abc The Collections Abstract Base Classes in the collections module are deprecated since Python 3.3 in favor of collections.abc, and removed in Python 3.10.

import os
import time


class mocktime:
    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'))