From f203f4826c3e9e8b7746f8ed3a32f76d0ad844ed Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Fri, 16 Apr 2004 13:56:39 +0000 Subject: [PATCH] testsuite/pipeline.py (PipelineConstructor.testGoodConstructor) (PipelineConstructor.testBadConstruct) Original commit message from CVS: * testsuite/pipeline.py (PipelineConstructor.testGoodConstructor) (PipelineConstructor.testBadConstruct) (ThreadConstructor.testCreate): New tests * testsuite/element.py (ElementTest.testGoodConstructor): Add isinstance(element, gst.Element) test * testsuite/common.py: Clean up, use ltihooks (init) Assign tp_new for pipeline and thread to PyType_GenericNew for now. --- ChangeLog | 13 ++++++++++++- gst/gst.override | 7 +++++++ testsuite/Makefile.am | 2 +- testsuite/common.py | 37 ++++++++++++++----------------------- testsuite/element.py | 3 ++- testsuite/pipeline.py | 21 +++++++++++++++++++-- testsuite/test_element.py | 3 ++- testsuite/test_pipeline.py | 21 +++++++++++++++++++-- 8 files changed, 76 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5d8f6b..cafb31b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,20 @@ 2004-04-16 Johan Dahlin + * testsuite/pipeline.py (PipelineConstructor.testGoodConstructor) + (PipelineConstructor.testBadConstruct) + (ThreadConstructor.testCreate): New tests + + * testsuite/element.py (ElementTest.testGoodConstructor): Add + isinstance(element, gst.Element) test + + * testsuite/common.py: Clean up, use ltihooks + * gst/gst.override (_wrap_gst_element_tp_new): New, just pointing to _wrap_gst_element_factory_make (_wrap_gst_element_tp_new): Stub, return 1 so tp_new can be used. - + (init) Assign tp_new for pipeline and thread to PyType_GenericNew + for now. + * gst/gst.defs (element_factory_make): Remove is-constructor-of GstElement. diff --git a/gst/gst.override b/gst/gst.override index 84205a4..95b1a1f 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -1058,3 +1058,10 @@ _wrap_gst_element_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { return _wrap_gst_element_factory_make(NULL, args, kwargs); } +%% +init +/* This is due to a bug in PyGTK 2.3.91, should be removed when we can require + * a newer version. + */ +PyGstPipeline_Type.tp_new = PyType_GenericNew; +PyGstThread_Type.tp_new = PyType_GenericNew; diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index ba900d9..e421017 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -2,7 +2,7 @@ tests = \ common.py \ element.py \ interface.py \ - pipeline.py + pipeline.py check-local: @PYTHONPATH=$(top_builddir) $(PYTHON) $(srcdir)/runtests.py diff --git a/testsuite/common.py b/testsuite/common.py index 3949221..7d8927d 100644 --- a/testsuite/common.py +++ b/testsuite/common.py @@ -3,38 +3,29 @@ import os import sys import unittest -devloc = os.path.join('..', 'gst', '.libs') -if os.path.exists(devloc): - sys.path.insert(0, devloc) +# Don't insert before . +sys.path.insert(1, os.path.join('..', 'gst')) -# Load GST and make sure we load it from the current build +import ltihooks +# Load GST and make sure we load it from the current build sys.setdlopenflags(dl.RTLD_LAZY | dl.RTLD_GLOBAL) -# We're importing _gst, since we don't have access to __init__.py -# during distcheck where builddir != srcdir -import _gst as gst - -# Put the fake module in sys.modules, otherwise the C modules -# Can't find the classes accordingly -sys.modules['gst'] = gst +path = os.path.abspath(os.path.join('..', 'gst')) +import gst +assert gst.__path__ != path, 'bad path' try: - import interfaces - gst.interfaces = interfaces - sys.modules['gst.interfaces'] = interfaces + import gst.interfaces + assert os.path.basename(gst.interfaces.__file__) != path, 'bad path' except ImportError: - pass + pass try: - import play - gst.play = play - sys.modules['gst.play'] = play + import gst.play + assert os.path.basename(gst.play.__file__) != path, 'bad path' except ImportError: - pass + pass + -assert sys.modules.has_key('_gst') -assert os.path.basename(sys.modules['_gst'].__file__), \ - os.path.join('..', 'gst', 'libs') -del devloc, sys, os, dl diff --git a/testsuite/element.py b/testsuite/element.py index 93cc905..5adb4c8 100644 --- a/testsuite/element.py +++ b/testsuite/element.py @@ -14,7 +14,8 @@ class ElementTest(unittest.TestCase): def testGoodConstructor(self): element = gst.Element(self.name, self.alias) - assert element + assert element is not None, 'element is None' + assert isinstance(element, gst.Element) assert element.get_name() == self.alias class FakeSinkTest(ElementTest): diff --git a/testsuite/pipeline.py b/testsuite/pipeline.py index e75fc2f..fec4611 100644 --- a/testsuite/pipeline.py +++ b/testsuite/pipeline.py @@ -1,9 +1,26 @@ from common import gst, unittest -class PipelineTest(unittest.TestCase): +class PipelineConstructor(unittest.TestCase): + def testBadConstruct(self): + self.assertRaises(TypeError, gst.Pipeline) + self.assertRaises(TypeError, gst.Pipeline, None) + + def testGoodConstructor(self): + name = 'test-pipeline' + pipeline = gst.Pipeline(name) + assert pipeline is not None, 'pipeline is None' + assert isinstance(pipeline, gst.Pipeline), 'pipeline is not a GstPipline' + assert pipeline.get_name() == name, 'pipelines name is wrong' + +class ThreadConstructor(unittest.TestCase): + def testCreate(self): + thread = gst.Thread('test-thread') + assert thread is not None, 'thread is None' + assert isinstance(thread, gst.Thread) + +class Pipeline(unittest.TestCase): def setUp(self): self.pipeline = gst.Pipeline('test-pipeline') - source = gst.Element('fakesrc', 'source') source.set_property('num-buffers', 5) sink = gst.Element('fakesink', 'sink') diff --git a/testsuite/test_element.py b/testsuite/test_element.py index 93cc905..5adb4c8 100644 --- a/testsuite/test_element.py +++ b/testsuite/test_element.py @@ -14,7 +14,8 @@ class ElementTest(unittest.TestCase): def testGoodConstructor(self): element = gst.Element(self.name, self.alias) - assert element + assert element is not None, 'element is None' + assert isinstance(element, gst.Element) assert element.get_name() == self.alias class FakeSinkTest(ElementTest): diff --git a/testsuite/test_pipeline.py b/testsuite/test_pipeline.py index e75fc2f..fec4611 100644 --- a/testsuite/test_pipeline.py +++ b/testsuite/test_pipeline.py @@ -1,9 +1,26 @@ from common import gst, unittest -class PipelineTest(unittest.TestCase): +class PipelineConstructor(unittest.TestCase): + def testBadConstruct(self): + self.assertRaises(TypeError, gst.Pipeline) + self.assertRaises(TypeError, gst.Pipeline, None) + + def testGoodConstructor(self): + name = 'test-pipeline' + pipeline = gst.Pipeline(name) + assert pipeline is not None, 'pipeline is None' + assert isinstance(pipeline, gst.Pipeline), 'pipeline is not a GstPipline' + assert pipeline.get_name() == name, 'pipelines name is wrong' + +class ThreadConstructor(unittest.TestCase): + def testCreate(self): + thread = gst.Thread('test-thread') + assert thread is not None, 'thread is None' + assert isinstance(thread, gst.Thread) + +class Pipeline(unittest.TestCase): def setUp(self): self.pipeline = gst.Pipeline('test-pipeline') - source = gst.Element('fakesrc', 'source') source.set_property('num-buffers', 5) sink = gst.Element('fakesink', 'sink') -- 2.7.4