Skip to content

Commit 97ecf34

Browse files
authored
Move "fake_time" fixture to conftest.py (#639)
"conftest.py" contains fixtures that are shared among multiple test cases. Fixes #223
2 parents a889296 + 879662d commit 97ecf34

File tree

5 files changed

+8
-28
lines changed

5 files changed

+8
-28
lines changed

tests/actor/test_resampling.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ def event_loop() -> Iterator[async_solipsism.EventLoop]:
3535
loop.close()
3636

3737

38-
@pytest.fixture
39-
def fake_time() -> Iterator[time_machine.Coordinates]:
40-
"""Replace real time with a time machine that doesn't automatically tick."""
41-
with time_machine.travel(0, tick=False) as traveller:
42-
yield traveller
43-
44-
4538
def _now() -> datetime:
4639
return datetime.now(timezone.utc)
4740

tests/actor/test_run_utils.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ def event_loop() -> Iterator[async_solipsism.EventLoop]:
2323
loop.close()
2424

2525

26-
@pytest.fixture
27-
def fake_time() -> Iterator[time_machine.Coordinates]:
28-
"""Replace real time with a time machine that doesn't automatically tick."""
29-
with time_machine.travel(0, tick=False) as traveller:
30-
yield traveller
31-
32-
3326
class FaultyActor(Actor):
3427
"""A test faulty actor."""
3528

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from datetime import timedelta
88

99
import pytest
10+
import time_machine
1011

1112
from frequenz.sdk.actor import _actor
1213

@@ -52,3 +53,10 @@ def actor_auto_restart_once() -> Iterator[None]:
5253
"""Make actors restart only once."""
5354
with actor_restart_limit(1):
5455
yield
56+
57+
58+
@pytest.fixture
59+
def fake_time() -> Iterator[time_machine.Coordinates]:
60+
"""Replace real time with a time machine that doesn't automatically tick."""
61+
with time_machine.travel(0, tick=False) as traveller:
62+
yield traveller

tests/timeseries/test_moving_window.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ def event_loop() -> Iterator[async_solipsism.EventLoop]:
2828
loop.close()
2929

3030

31-
@pytest.fixture
32-
def fake_time() -> Iterator[time_machine.Coordinates]:
33-
"""Replace real time with a time machine that doesn't automatically tick."""
34-
with time_machine.travel(0, tick=False) as traveller:
35-
yield traveller
36-
37-
3831
async def push_logical_meter_data(
3932
sender: Sender[Sample[Quantity]], test_seq: Sequence[float]
4033
) -> None:

tests/timeseries/test_resampling.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ def event_loop() -> Iterator[async_solipsism.EventLoop]:
4646
loop.close()
4747

4848

49-
@pytest.fixture
50-
def fake_time() -> Iterator[time_machine.Coordinates]:
51-
"""Replace real time with a time machine that doesn't automatically tick."""
52-
with time_machine.travel(0, tick=False) as traveller:
53-
yield traveller
54-
55-
5649
@pytest.fixture
5750
async def source_chan() -> AsyncIterator[Broadcast[Sample[Quantity]]]:
5851
"""Create a broadcast channel of samples."""

0 commit comments

Comments
 (0)