Skip to content

Commit

Permalink
workaround for spulec/freezegun#309, fixes: #209
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Sep 19, 2019
1 parent 22f3926 commit 9757e42
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import freezegun
import progressbar
from datetime import datetime


LOG_LEVELS = {
Expand All @@ -29,7 +30,12 @@ def small_interval(monkeypatch):

@pytest.fixture(autouse=True)
def sleep_faster(monkeypatch):
freeze_time = freezegun.freeze_time()
# The timezone offset in seconds, add 10 seconds to make sure we don't
# accidently get the wrong hour
offset_seconds = (datetime.now() - datetime.utcnow()).seconds + 10
offset_hours = int(offset_seconds / 3600)

freeze_time = freezegun.freeze_time(tz_offset=offset_hours)
with freeze_time as fake_time:
monkeypatch.setattr('time.sleep', fake_time.tick)
monkeypatch.setattr('timeit.default_timer', time.time)
Expand Down

0 comments on commit 9757e42

Please sign in to comment.