tests/mockmakedate.py
author Yuya Nishihara <yuya@tcha.org>
Fri, 17 Apr 2020 19:35:18 +0900
changeset 44732 f44a7d8660ea
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
test-check-rust-format: specify --edition=2018 rustfmt doesn't read Cargo.toml unless it's executed by cargo. https://github.com/rust-lang/rustfmt#rusts-editions

# 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