• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from __future__ import print_function, division, absolute_import
2from fontTools.misc.py23 import *
3from fontTools.misc.timeTools import asctime, timestampNow, epoch_diff
4import os
5import time
6import pytest
7
8
9def test_asctime():
10    assert isinstance(asctime(), basestring)
11    assert asctime(time.gmtime(0)) == 'Thu Jan  1 00:00:00 1970'
12
13
14def test_source_date_epoch():
15    os.environ["SOURCE_DATE_EPOCH"] = "150687315"
16    assert timestampNow() + epoch_diff == 150687315
17
18    # Check that malformed value fail, any better way?
19    os.environ["SOURCE_DATE_EPOCH"] = "ABCDEFGHI"
20    with pytest.raises(ValueError):
21        timestampNow()
22
23    del os.environ["SOURCE_DATE_EPOCH"]
24    assert timestampNow() + epoch_diff != 150687315
25