tests/mockmakedate.py
author Matt Harbison <matt_harbison@yahoo.com>
Wed, 13 Jul 2022 11:30:13 -0400
changeset 49389 093e5c274f54
parent 48875 6000f5b25c9b
permissions -rw-r--r--
typing: suppress a few pyi-errors with more recent pytype Not sure what's going on here, but these were flagged with pytype 2022.03.21. We can't update to something much more recent, because newer versions complain about various `attr` uses.

# mock out util.makedate() to supply testable values


import os

from mercurial import pycompat
from mercurial.utils import dateutil


def mockmakedate():
    filename = os.path.join(os.environ['TESTTMP'], 'testtime')
    try:
        with open(filename, 'rb') as timef:
            time = float(timef.read()) + 1
    except IOError:
        time = 0.0
    with open(filename, 'wb') as timef:
        timef.write(pycompat.bytestr(time))
    return (time, 0)


dateutil.makedate = mockmakedate