tests: Simple test to use gst-full in python
authorThibault Saunier <tsaunier@igalia.com>
Fri, 8 Oct 2021 01:34:38 +0000 (22:34 -0300)
committerThibault Saunier <tsaunier@igalia.com>
Fri, 15 Oct 2021 22:28:14 +0000 (19:28 -0300)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1093>

tests/python/meson.build
tests/python/python-full.py [new file with mode: 0755]

index b391044..c41fd0b 100644 (file)
@@ -16,4 +16,19 @@ endif
 test('python-overrides-devenv', setenv, args: ['--builddir=@0@'.format(meson.build_root()),
               '--gstbuilddir=@0@'.format(meson.current_build_dir() / '..' / '..'),
               '--srcdir=@0@'.format(meson.source_root()),
-              meson.current_source_dir() / 'python-devenv-overrides.py'])
\ No newline at end of file
+              meson.current_source_dir() / 'python-devenv-overrides.py'])
+
+env = environment()
+env.set('GI_TYPELIB_PATH', meson.current_build_dir() / root_rel)
+if build_machine.system() == 'windows'
+    env.append('PATH', meson.current_build_dir() / root_rel)
+elif build_machine.system() == 'linux'
+    env.append('LD_LIBRARY_PATH', meson.current_build_dir() / root_rel)
+else
+    env.append('DYLD_LIBRARY_PATH', meson.current_build_dir() / root_rel)
+endif
+
+env.set('GST_OVERRIDE_SRC_PATH', meson.current_source_dir() / root_rel / 'subprojects/gst-python/gi/overrides')
+env.set('GST_OVERRIDE_BUILD_PATH', meson.current_build_dir() / root_rel / 'subprojects/gst-python/gi/overrides')
+
+test('python-full', python, args: [meson.current_source_dir() / 'python-full.py'], env: env)
diff --git a/tests/python/python-full.py b/tests/python/python-full.py
new file mode 100755 (executable)
index 0000000..93f8d30
--- /dev/null
@@ -0,0 +1,22 @@
+import sys
+from pathlib import Path
+
+sys.path.append(str(Path(__file__).parent / "../../subprojects/gst-python/testsuite"))
+
+import overrides_hack
+
+overrides_hack
+
+from common import TestCase, unittest
+from gi.repository import Gst
+
+
+class TestBin(TestCase):
+    def test(self):
+        Gst.init(None)
+        self.assertEqual(Gst.ElementFactory.make("bin", None).sinkpads, [])
+        self.assertEqual(float(Gst.Fraction(1, 2)), 0.5)
+
+
+if __name__ == "__main__":
+    unittest.main()