tests/mocktime.py
author Yuya Nishihara <yuya@tcha.org>
Tue, 15 Oct 2019 22:44:55 +0900
changeset 43484 8d5489b048b7
parent 43076 2372284d9457
child 48966 6000f5b25c9b
permissions -rw-r--r--
py3: enable legacy fs encoding to fix filename compatibility on Windows This patch is untested. I just followed the instruction: https://docs.python.org/3/whatsnew/3.6.html#pep-529-change-windows-filesystem-encoding-to-utf-8

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