Make tests run headless using xvfbwrapper
This commit is contained in:
parent
4eb105a751
commit
068d034cc0
2 changed files with 14 additions and 1 deletions
13
mpv-test.py
13
mpv-test.py
|
|
@ -19,6 +19,8 @@ import ctypes
|
||||||
|
|
||||||
import mpv
|
import mpv
|
||||||
|
|
||||||
|
from xvfbwrapper import Xvfb
|
||||||
|
|
||||||
|
|
||||||
# stdout magic to suppress useless libmpv warning messages in unittest output
|
# stdout magic to suppress useless libmpv warning messages in unittest output
|
||||||
# See https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/
|
# See https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/
|
||||||
|
|
@ -62,10 +64,13 @@ MPV_ERRORS = [ l(ec) for ec, l in mpv.ErrorCode.EXCEPTION_DICT.items() if l ]
|
||||||
|
|
||||||
class MpvTestCase(unittest.TestCase):
|
class MpvTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.m = mpv.MPV()
|
self.disp = Xvfb()
|
||||||
|
self.disp.start()
|
||||||
|
self.m = mpv.MPV(vo='x11')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.m.terminate()
|
self.m.terminate()
|
||||||
|
self.disp.stop()
|
||||||
|
|
||||||
class TestProperties(MpvTestCase):
|
class TestProperties(MpvTestCase):
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|
@ -407,6 +412,8 @@ class TestStreams(unittest.TestCase):
|
||||||
def test_python_stream(self):
|
def test_python_stream(self):
|
||||||
handler = mock.Mock()
|
handler = mock.Mock()
|
||||||
|
|
||||||
|
disp = Xvfb()
|
||||||
|
disp.start()
|
||||||
m = mpv.MPV()
|
m = mpv.MPV()
|
||||||
m.register_event_callback(handler)
|
m.register_event_callback(handler)
|
||||||
|
|
||||||
|
|
@ -452,6 +459,7 @@ class TestStreams(unittest.TestCase):
|
||||||
handler.reset_mock()
|
handler.reset_mock()
|
||||||
|
|
||||||
m.terminate()
|
m.terminate()
|
||||||
|
disp.stop()
|
||||||
|
|
||||||
def test_custom_stream(self):
|
def test_custom_stream(self):
|
||||||
handler = mock.Mock()
|
handler = mock.Mock()
|
||||||
|
|
@ -460,6 +468,8 @@ class TestStreams(unittest.TestCase):
|
||||||
stream_mock.seek = mock.Mock(return_value=0)
|
stream_mock.seek = mock.Mock(return_value=0)
|
||||||
stream_mock.read = mock.Mock(return_value=b'')
|
stream_mock.read = mock.Mock(return_value=b'')
|
||||||
|
|
||||||
|
disp = Xvfb()
|
||||||
|
disp.start()
|
||||||
m = mpv.MPV(video=False)
|
m = mpv.MPV(video=False)
|
||||||
m.register_event_callback(handler)
|
m.register_event_callback(handler)
|
||||||
|
|
||||||
|
|
@ -487,6 +497,7 @@ class TestStreams(unittest.TestCase):
|
||||||
handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.UNKNOWN_FORMAT}})
|
handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.UNKNOWN_FORMAT}})
|
||||||
|
|
||||||
m.terminate()
|
m.terminate()
|
||||||
|
disp.stop()
|
||||||
|
|
||||||
class TestLifecycle(unittest.TestCase):
|
class TestLifecycle(unittest.TestCase):
|
||||||
def test_create_destroy(self):
|
def test_create_destroy(self):
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -13,6 +13,8 @@ setup(
|
||||||
extras_require = {
|
extras_require = {
|
||||||
'screenshot_raw': ['Pillow']
|
'screenshot_raw': ['Pillow']
|
||||||
},
|
},
|
||||||
|
tests_require = ['xvfbwrapper'],
|
||||||
|
test_suite = 'mpv-test',
|
||||||
keywords = ['mpv', 'library', 'video', 'audio', 'player', 'display',
|
keywords = ['mpv', 'library', 'video', 'audio', 'player', 'display',
|
||||||
'multimedia'],
|
'multimedia'],
|
||||||
classifiers = [
|
classifiers = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue