Skip to content
Snippets Groups Projects
Commit 74ad2d91 authored by Georg Koppen's avatar Georg Koppen
Browse files

Use freeze_time() in other parts of our tests, too

When using `_relays_with_flags()` and similar methods it's possible
that tests start to hang without time freezing. See bug 33748 for more
details. We work around this by providing the necessary `freeze_time()`
calls meanwhile.
parent 3efb6867
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ import pytest
import os.path
from unittest import mock
from freezegun import freeze_time
from stem import descriptor
from sbws import settings
......@@ -120,7 +121,8 @@ def router_status(server_descriptor, router_statuses):
@pytest.fixture(scope='function')
def relay_list(args, conf, controller):
"""Returns a RelayList containing the Relays in the controller"""
return relaylist.RelayList(args, conf, controller)
with freeze_time("2020-02-29 10:00:00"):
return relaylist.RelayList(args, conf, controller)
@pytest.fixture(scope='function')
......
......@@ -71,9 +71,8 @@ def test_increment_recent_measurement_attempt(args, conf, controller):
It also tests that the state file is updated correctly.
"""
state = State(conf['paths']['state_fpath'])
# For this test it does not matter that the consensus timestamps or relays
# are not correct.
relay_list = RelayList(args, conf, controller=controller, state=state)
with freeze_time("2020-02-29 10:00:00"):
relay_list = RelayList(args, conf, controller=controller, state=state)
# The initial count is 0 and the state does not have that key.
assert 0 == relay_list.recent_measurement_attempt_count
assert not state.get("recent_measurement_attempt", None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment