Windows test workaround

Add dummy Xvfb implementation, parameterise vo and use gpu renderer for windows tests
This commit is contained in:
DepFA 2022-04-22 09:19:54 +01:00 committed by GitHub
parent 0f48db6398
commit 9148f544eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,9 +32,21 @@ import platform
import ctypes import ctypes
from concurrent.futures import Future from concurrent.futures import Future
os.environ["PATH"] = os.path.dirname(__file__) + os.pathsep + os.environ["PATH"]
import mpv 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') TESTVID = os.path.join(os.path.dirname(__file__), 'test.webm')
@ -51,7 +63,7 @@ class MpvTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() 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): def tearDown(self):
self.m.terminate() self.m.terminate()
@ -438,7 +450,7 @@ class TestStreams(unittest.TestCase):
disp = Xvfb() disp = Xvfb()
disp.start() disp.start()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.register_event_callback(handler) m.register_event_callback(handler)
@m.python_stream('foo') @m.python_stream('foo')
@ -494,7 +506,7 @@ class TestStreams(unittest.TestCase):
disp = Xvfb() disp = Xvfb()
disp.start() disp.start()
m = mpv.MPV(vo='x11', video=False) m = mpv.MPV(vo=testvo, video=False)
m.register_event_callback(handler) m.register_event_callback(handler)
m.register_stream_protocol('pythonfail', fail_mock) m.register_stream_protocol('pythonfail', fail_mock)
@ -570,7 +582,7 @@ class TestLifecycle(unittest.TestCase):
def test_wait_for_property_negative(self): def test_wait_for_property_negative(self):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.play(TESTVID) m.play(TESTVID)
result = Future() result = Future()
def run(): def run():
@ -593,7 +605,7 @@ class TestLifecycle(unittest.TestCase):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
handler = mock.Mock() handler = mock.Mock()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.play(TESTVID) m.play(TESTVID)
def run(): def run():
nonlocal self nonlocal self
@ -612,7 +624,7 @@ class TestLifecycle(unittest.TestCase):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
handler = mock.Mock() handler = mock.Mock()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.play(TESTVID) m.play(TESTVID)
result = Future() result = Future()
def run(): def run():
@ -635,7 +647,7 @@ class TestLifecycle(unittest.TestCase):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
handler = mock.Mock() handler = mock.Mock()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.play(TESTVID) m.play(TESTVID)
with self.assertRaises(mpv.ShutdownError): with self.assertRaises(mpv.ShutdownError):
# level_sensitive=false needed to prevent get_property on dead # 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): def test_wait_for_event_shutdown(self):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.play(TESTVID) m.play(TESTVID)
with self.assertRaises(mpv.ShutdownError): with self.assertRaises(mpv.ShutdownError):
with m.prepare_and_wait_for_event('seek'): with m.prepare_and_wait_for_event('seek'):
@ -658,7 +670,7 @@ class TestLifecycle(unittest.TestCase):
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
handler = mock.Mock() handler = mock.Mock()
m = mpv.MPV(vo='x11') m = mpv.MPV(vo=testvo)
m.play(TESTVID) m.play(TESTVID)
with self.assertRaises(mpv.ShutdownError): with self.assertRaises(mpv.ShutdownError):
with m.prepare_and_wait_for_event(None) as result: with m.prepare_and_wait_for_event(None) as result:
@ -670,7 +682,7 @@ class TestLifecycle(unittest.TestCase):
handler = mock.Mock() handler = mock.Mock()
self.disp = Xvfb() self.disp = Xvfb()
self.disp.start() self.disp.start()
m = mpv.MPV(vo='x11', log_handler=handler) m = mpv.MPV(vo=testvo, log_handler=handler)
m.play(TESTVID) m.play(TESTVID)
# Wait for playback to start # Wait for playback to start
m.wait_until_playing() m.wait_until_playing()