diff options
author | DepFA <35278260+dfaker@users.noreply.github.com> | 2022-04-22 09:19:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 09:19:54 +0100 |
commit | 9148f544eb761440a05264550b82888ebc03f547 (patch) | |
tree | 96f238c9c653f60c5f70cd8d96f1031986892474 /tests/test_mpv.py | |
parent | 0f48db6398dd573476d173be811eef45169e4259 (diff) | |
download | python-mpv-9148f544eb761440a05264550b82888ebc03f547.tar.gz python-mpv-9148f544eb761440a05264550b82888ebc03f547.tar.bz2 python-mpv-9148f544eb761440a05264550b82888ebc03f547.zip |
Windows test workaround
Add dummy Xvfb implementation, parameterise vo and use gpu renderer for windows tests
Diffstat (limited to 'tests/test_mpv.py')
-rwxr-xr-x | tests/test_mpv.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/tests/test_mpv.py b/tests/test_mpv.py index 26f4cbd..a9aad9f 100755 --- a/tests/test_mpv.py +++ b/tests/test_mpv.py @@ -32,9 +32,21 @@ import platform import ctypes from concurrent.futures import Future +os.environ["PATH"] = os.path.dirname(__file__) + os.pathsep + os.environ["PATH"] + import mpv -from xvfbwrapper import Xvfb + +if os.name == 'nt': + testvo='gpu' + class Xvfb(): + def __init__(self): pass + def start(self): pass + def stop(self): pass + +else: + from xvfbwrapper import Xvfb + testvo='x11' TESTVID = os.path.join(os.path.dirname(__file__), 'test.webm') @@ -51,7 +63,7 @@ class MpvTestCase(unittest.TestCase): def setUp(self): self.disp = Xvfb() self.disp.start() - self.m = mpv.MPV(vo='x11', loglevel='debug', log_handler=timed_print()) + self.m = mpv.MPV(vo=testvo, loglevel='debug', log_handler=timed_print()) def tearDown(self): self.m.terminate() @@ -438,7 +450,7 @@ class TestStreams(unittest.TestCase): disp = Xvfb() disp.start() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.register_event_callback(handler) @m.python_stream('foo') @@ -494,7 +506,7 @@ class TestStreams(unittest.TestCase): disp = Xvfb() disp.start() - m = mpv.MPV(vo='x11', video=False) + m = mpv.MPV(vo=testvo, video=False) m.register_event_callback(handler) m.register_stream_protocol('pythonfail', fail_mock) @@ -570,7 +582,7 @@ class TestLifecycle(unittest.TestCase): def test_wait_for_property_negative(self): self.disp = Xvfb() self.disp.start() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.play(TESTVID) result = Future() def run(): @@ -593,7 +605,7 @@ class TestLifecycle(unittest.TestCase): self.disp = Xvfb() self.disp.start() handler = mock.Mock() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.play(TESTVID) def run(): nonlocal self @@ -612,7 +624,7 @@ class TestLifecycle(unittest.TestCase): self.disp = Xvfb() self.disp.start() handler = mock.Mock() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.play(TESTVID) result = Future() def run(): @@ -635,7 +647,7 @@ class TestLifecycle(unittest.TestCase): self.disp = Xvfb() self.disp.start() handler = mock.Mock() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.play(TESTVID) with self.assertRaises(mpv.ShutdownError): # level_sensitive=false needed to prevent get_property on dead @@ -647,7 +659,7 @@ class TestLifecycle(unittest.TestCase): def test_wait_for_event_shutdown(self): self.disp = Xvfb() self.disp.start() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.play(TESTVID) with self.assertRaises(mpv.ShutdownError): with m.prepare_and_wait_for_event('seek'): @@ -658,7 +670,7 @@ class TestLifecycle(unittest.TestCase): self.disp = Xvfb() self.disp.start() handler = mock.Mock() - m = mpv.MPV(vo='x11') + m = mpv.MPV(vo=testvo) m.play(TESTVID) with self.assertRaises(mpv.ShutdownError): with m.prepare_and_wait_for_event(None) as result: @@ -670,7 +682,7 @@ class TestLifecycle(unittest.TestCase): handler = mock.Mock() self.disp = Xvfb() self.disp.start() - m = mpv.MPV(vo='x11', log_handler=handler) + m = mpv.MPV(vo=testvo, log_handler=handler) m.play(TESTVID) # Wait for playback to start m.wait_until_playing() |