testsuite/pipeline.py (PipelineConstructor.testGoodConstructor) (PipelineConstructor...
authorJohan Dahlin <johan@gnome.org>
Fri, 16 Apr 2004 13:56:39 +0000 (13:56 +0000)
committerJohan Dahlin <johan@gnome.org>
Fri, 16 Apr 2004 13:56:39 +0000 (13:56 +0000)
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
gst/gst.override
testsuite/Makefile.am
testsuite/common.py
testsuite/element.py
testsuite/pipeline.py
testsuite/test_element.py
testsuite/test_pipeline.py

index e5d8f6b..cafb31b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,20 @@
 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.
 
index 84205a4..95b1a1f 100644 (file)
@@ -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;
index ba900d9..e421017 100644 (file)
@@ -2,7 +2,7 @@ tests =  \
        common.py \
        element.py \
        interface.py \
-       pipeline.py 
+       pipeline.py
 
 check-local:
        @PYTHONPATH=$(top_builddir) $(PYTHON) $(srcdir)/runtests.py
index 3949221..7d8927d 100644 (file)
@@ -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
index 93cc905..5adb4c8 100644 (file)
@@ -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):
index e75fc2f..fec4611 100644 (file)
@@ -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')
index 93cc905..5adb4c8 100644 (file)
@@ -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):
index e75fc2f..fec4611 100644 (file)
@@ -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')