2004-04-16 Johan Dahlin <johan@gnome.org>
+ * 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.
{
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;
common.py \
element.py \
interface.py \
- pipeline.py
+ pipeline.py
check-local:
@PYTHONPATH=$(top_builddir) $(PYTHON) $(srcdir)/runtests.py
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
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):
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')
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):
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')