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.
This commit is contained in:
Johan Dahlin 2004-04-16 13:56:39 +00:00
parent 9e4049710c
commit f203f4826c
8 changed files with 76 additions and 31 deletions

View file

@ -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.

View 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;

View 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

View 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'))
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

View 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):

View 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')

View 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):

View 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')