tests/mockmakedate.py
author Gregory Szorc <gregory.szorc@gmail.com>
Sun, 19 Apr 2020 17:33:08 -0700
branchstable
changeset 44743 036f6f7e19e1
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
packaging: add docutils as dependency The previous commit revealed that attempting to run `python setup.py build_doc` from the packaging virtualenv failed due to missing docutils package. We didn't notice this before because py2exe Windows packaging appears to use a Python from another virtualenv (which does include docutils) to invoke setup.py. I discovered this as part of implementing packaging outside of that virtualenv environment. Differential Revision: https://phab.mercurial-scm.org/D8470

# 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