freezegun icon indicating copy to clipboard operation
freezegun copied to clipboard

Using tz_offset breaks t == fromtimestamp(t).timestamp()

Open Strilanc opened this issue 5 years ago • 0 comments

import freezegun

def test_without_freezegun():
    t = datetime.datetime.now().timestamp()
    t2 = datetime.datetime.fromtimestamp(t).timestamp()
    assert t == t2  # PASS


@freezegun.freeze_time(datetime.datetime.fromtimestamp(100_000), tz_offset=-1)
def test_with_freezegun():
    t = datetime.datetime.now().timestamp()
    t2 = datetime.datetime.fromtimestamp(t).timestamp()
    assert t == t2  # FAIL

Strilanc avatar Apr 01 '20 17:04 Strilanc