fonttools/Tests/misc/timeTools_test.py
Khaled Hosny 4b3a2eb1d9 Respect SOURCE_DATE_EPOCH for time stamp
For reproducible builds, check the presence of SOURCE_DATE_EPOCH
environment variable and use it for the time stamp. This affects the
head.modified (and head.created in merge.py).

See https://reproducible-builds.org/specs/source-date-epoch/
2017-10-02 11:37:00 +02:00

26 lines
752 B
Python

from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.misc.timeTools import asctime, timestampNow, epoch_diff
import os
import time
def test_asctime():
assert isinstance(asctime(), basestring)
assert asctime(time.gmtime(0)) == 'Thu Jan 1 00:00:00 1970'
def test_source_date_epoch():
os.environ["SOURCE_DATE_EPOCH"] = "150687315"
assert timestampNow() + epoch_diff == 150687315
# Check that malformed value fail, any better way?
os.environ["SOURCE_DATE_EPOCH"] = "ABCDEFGHI"
try:
timestampNow()
assert False
except ValueError:
assert True
del os.environ["SOURCE_DATE_EPOCH"]
assert timestampNow() + epoch_diff != 150687315