From 141ec7d372c8d536c208c39bb89132d69aa1b36c Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 22 Jan 2024 11:48:47 +0100 Subject: mpv.py: Add play_context convenience function --- tests/test_mpv.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/test_mpv.py b/tests/test_mpv.py index 74999ad..9cc688d 100755 --- a/tests/test_mpv.py +++ b/tests/test_mpv.py @@ -643,6 +643,26 @@ class TestStreams(unittest.TestCase): m.terminate() disp.stop() + def test_play_context(self): + handler = mock.Mock() + + disp = Display() + disp.start() + m = mpv.MPV(vo=testvo) + def cb(evt): + handler(evt.as_dict(decoder=mpv.lazy_decoder)) + m.register_event_callback(cb) + + with m.play_context() as write: + with open(TESTVID, 'rb') as f: + write(f.read(100)) + write(f.read(1000)) + write(f.read()) + + m.wait_for_playback() + handler.assert_any_call({'event': 'end-file', 'reason': 'eof', 'playlist_entry_id': 1}) + m.terminate() + disp.stop() class TestLifecycle(unittest.TestCase): -- cgit