Skip to content

Commit

Permalink
fix some pytest resource warning
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Jan 7, 2025
1 parent 3062f04 commit 7cc4433
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/player/test_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def test_set_current_song_with_media(pl, song2):
Set a non-existing song as current song,
and the song should be inserted after current_song.
"""
# Mock the a_next coroutine to avoid resource leak::
# RuntimeWarning: coroutine 'Playlist.a_next' was never awaited
pl.a_next = mock.MagicMock(return_value=asyncio.Future())
pl.set_current_song_with_media(song2, None)
assert pl.current_song == song2
assert pl.list()[1] == song2
Expand All @@ -92,11 +95,10 @@ def test_set_current_song_with_media(pl, song2):
async def test_play_model(pl, app_mock, song, mocker):
f = asyncio.Future()
f.set_result(None)
mocker.patch.object(pl, 'set_current_model', return_value=f)
app_mock.task_mgr.run_afn_preemptive.return_value = f
await pl.a_play_model(song)
# The player.resume method must be called.
assert pl._app.player.resume.called
assert app_mock.player.resume.called


@pytest.mark.asyncio
Expand Down

0 comments on commit 7cc4433

Please sign in to comment.