Skip to content

Commit 84a0c0f

Browse files
committed
Use _Mocks.stop() to cleanup
The _Mocks class already provides a `.stop()` methods to cleanup, so use that to avoid duplicated code. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 0ec6cb8 commit 84a0c0f

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

tests/timeseries/_ev_charger_pool/test_ev_charger_pool_control_methods.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,15 @@ async def mocks(mocker: MockerFixture) -> AsyncIterator[_Mocks]:
5858

5959
dp = cast(_DataPipeline, microgrid._data_pipeline._DATA_PIPELINE)
6060

61+
_mocks = _Mocks(
62+
mockgrid,
63+
streamer,
64+
dp._ev_power_wrapper.status_channel.new_sender(),
65+
)
6166
try:
62-
yield _Mocks(
63-
mockgrid,
64-
streamer,
65-
dp._ev_power_wrapper.status_channel.new_sender(),
66-
)
67+
yield _mocks
6768
finally:
68-
_ = await asyncio.gather(
69-
*[
70-
dp._stop(),
71-
streamer.stop(),
72-
mockgrid.cleanup(),
73-
]
74-
)
69+
await _mocks.stop()
7570

7671

7772
class TestEVChargerPoolControl:

tests/timeseries/_pv_pool/test_pv_pool_control_methods.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,15 @@ async def mocks(mocker: MockerFixture) -> typing.AsyncIterator[_Mocks]:
5151

5252
dp = typing.cast(_DataPipeline, microgrid._data_pipeline._DATA_PIPELINE)
5353

54+
_mocks = _Mocks(
55+
mockgrid,
56+
streamer,
57+
dp._pv_power_wrapper.status_channel.new_sender(),
58+
)
5459
try:
55-
yield _Mocks(
56-
mockgrid,
57-
streamer,
58-
dp._pv_power_wrapper.status_channel.new_sender(),
59-
)
60+
yield _mocks
6061
finally:
61-
_ = await asyncio.gather(
62-
*[
63-
dp._stop(),
64-
streamer.stop(),
65-
mockgrid.cleanup(),
66-
]
67-
)
62+
await _mocks.stop()
6863

6964

7065
class TestPVPoolControl:

0 commit comments

Comments
 (0)