tests/mockmakedate.py
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 02 Nov 2019 13:08:20 -0700
branchstable
changeset 43390 5fa8ac91190e
parent 43076 2372284d9457
child 48966 6000f5b25c9b
permissions -rw-r--r--
fsmonitor: coerce watchman exception to bytes Without this, we get errors due to passing str to a function which expects bytes. Differential Revision: https://phab.mercurial-scm.org/D7206

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

from __future__ import absolute_import

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