2017-01-16 16:34:18 +00:00
|
|
|
from __future__ import print_function, division, absolute_import
|
|
|
|
from fontTools.misc.py23 import *
|
2017-10-02 10:27:31 +02:00
|
|
|
from fontTools.misc.timeTools import asctime, timestampNow, epoch_diff
|
|
|
|
import os
|
2017-01-16 16:34:18 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
def test_asctime():
|
|
|
|
assert isinstance(asctime(), basestring)
|
|
|
|
assert asctime(time.gmtime(0)) == 'Thu Jan 1 00:00:00 1970'
|
2017-10-02 10:27:31 +02:00
|
|
|
|
|
|
|
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
|