diff options
author | jaseg <code@jaseg.net> | 2020-04-05 12:46:57 +0200 |
---|---|---|
committer | jaseg <code@jaseg.net> | 2020-04-05 12:47:34 +0200 |
commit | 068d034cc0456a60dd7cdcbf696d6d537d6ec142 (patch) | |
tree | 828c9e9955ca3dc2d226647558ba77e4731b3092 | |
parent | 4eb105a75128a630868b8204ce2fa50252fc9bff (diff) | |
download | python-mpv-068d034cc0456a60dd7cdcbf696d6d537d6ec142.tar.gz python-mpv-068d034cc0456a60dd7cdcbf696d6d537d6ec142.tar.bz2 python-mpv-068d034cc0456a60dd7cdcbf696d6d537d6ec142.zip |
Make tests run headless using xvfbwrapper
-rwxr-xr-x | mpv-test.py | 13 | ||||
-rwxr-xr-x | setup.py | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/mpv-test.py b/mpv-test.py index 175555b..b9a3d65 100755 --- a/mpv-test.py +++ b/mpv-test.py @@ -19,6 +19,8 @@ import ctypes import mpv +from xvfbwrapper import Xvfb + # stdout magic to suppress useless libmpv warning messages in unittest output # 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): def setUp(self): - self.m = mpv.MPV() + self.disp = Xvfb() + self.disp.start() + self.m = mpv.MPV(vo='x11') def tearDown(self): self.m.terminate() + self.disp.stop() class TestProperties(MpvTestCase): @contextmanager @@ -407,6 +412,8 @@ class TestStreams(unittest.TestCase): def test_python_stream(self): handler = mock.Mock() + disp = Xvfb() + disp.start() m = mpv.MPV() m.register_event_callback(handler) @@ -452,6 +459,7 @@ class TestStreams(unittest.TestCase): handler.reset_mock() m.terminate() + disp.stop() def test_custom_stream(self): handler = mock.Mock() @@ -460,6 +468,8 @@ class TestStreams(unittest.TestCase): stream_mock.seek = mock.Mock(return_value=0) stream_mock.read = mock.Mock(return_value=b'') + disp = Xvfb() + disp.start() m = mpv.MPV(video=False) 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}}) m.terminate() + disp.stop() class TestLifecycle(unittest.TestCase): def test_create_destroy(self): @@ -13,6 +13,8 @@ setup( extras_require = { 'screenshot_raw': ['Pillow'] }, + tests_require = ['xvfbwrapper'], + test_suite = 'mpv-test', keywords = ['mpv', 'library', 'video', 'audio', 'player', 'display', 'multimedia'], classifiers = [ |