diff --git a/gst/gst.override b/gst/gst.override index ec4981f65e..439f2d0516 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -396,6 +396,7 @@ _wrap_gst_caps_new_empty(PyGBoxed *self, PyObject *args, PyObject *kwargs) len = PyTuple_Size(args); self->gtype = GST_TYPE_CAPS; self->free_on_dealloc = FALSE; + if (len == 0) { self->boxed = gst_caps_new_empty(); } else if (len == 1) { @@ -761,7 +762,6 @@ _wrap_gst_structure_ass_subscript(PyGObject *self, const char *key; GstStructure* structure; GValue value = { 0, }; - GType gtype; structure = (GstStructure*)self->obj; key = PyString_AsString(py_key); diff --git a/testsuite/caps.py b/testsuite/caps.py index 367eed1f5d..b5569a15c9 100644 --- a/testsuite/caps.py +++ b/testsuite/caps.py @@ -34,18 +34,22 @@ class CapsTest(unittest.TestCase): def testCapsConstructFromStructures(self): struct1 = gst.structure_from_string('video/x-raw-yuv,width=10') - struct2 = gst.structure_from_string('video/x-raw-rgb,width=20') + struct2 = gst.structure_from_string('video/x-raw-rgb,height=20.0') caps = gst.Caps(struct1, struct2) assert isinstance(caps, gst.Caps) assert len(caps) == 2 - assert isinstance(caps[0], gst.Structure) - assert isinstance(caps[1], gst.Structure) - assert caps[0].get_name() == 'video/x-raw-yuv' - assert caps[1].get_name() == 'video/x-raw-rgb' - assert isinstance(caps[0]['width'], int) - assert isinstance(caps[1]['width'], int) - assert caps[0]['width'] == 10 - assert caps[1]['width'] == 20 + struct = caps[0] + assert isinstance(struct, gst.Structure), struct + assert struct.get_name() == 'video/x-raw-yuv', struct.get_name() + assert struct.has_key('width') + assert isinstance(struct['width'], int) + assert struct['width'] == 10 + struct = caps[1] + assert isinstance(struct, gst.Structure), struct + assert struct.get_name() == 'video/x-raw-rgb', struct.get_name() + assert struct.has_key('height') + assert isinstance(struct['height'], float) + assert struct['height'] == 20.0 def testCapsStructureChange(self): 'test if changing the structure of the caps works by reference' @@ -56,5 +60,16 @@ class CapsTest(unittest.TestCase): structure = self.caps[0] assert structure['width'] == 5.0 + def testCapsBadConstructor(self): + struct = gst.structure_from_string('video/x-raw-yuv,width=10') + self.assertRaises(TypeError, gst.Caps, None) + self.assertRaises(TypeError, gst.Caps, 1) + self.assertRaises(TypeError, gst.Caps, 2.0) + self.assertRaises(TypeError, gst.Caps, object) + self.assertRaises(TypeError, gst.Caps, 1, 2, 3) + + # This causes segfault! + #self.assertRaises(TypeError, gst.Caps, struct, 10, None) + if __name__ == "__main__": unittest.main() diff --git a/testsuite/struct.py b/testsuite/struct.py index 252056c504..e51e2b3b4d 100644 --- a/testsuite/struct.py +++ b/testsuite/struct.py @@ -5,6 +5,9 @@ class StructureTest(unittest.TestCase): def setUp(self): self.struct = gst.structure_from_string('video/x-raw-yuv,width=10,foo="bar",pixel-aspect-ratio=1/2,framerate=5.0') + #def foo(self): + # gst.structure_from_string("foo") + def testName(self): assert self.struct.get_name() == 'video/x-raw-yuv' self.struct.set_name('foobar') diff --git a/testsuite/test_caps.py b/testsuite/test_caps.py index 367eed1f5d..b5569a15c9 100644 --- a/testsuite/test_caps.py +++ b/testsuite/test_caps.py @@ -34,18 +34,22 @@ class CapsTest(unittest.TestCase): def testCapsConstructFromStructures(self): struct1 = gst.structure_from_string('video/x-raw-yuv,width=10') - struct2 = gst.structure_from_string('video/x-raw-rgb,width=20') + struct2 = gst.structure_from_string('video/x-raw-rgb,height=20.0') caps = gst.Caps(struct1, struct2) assert isinstance(caps, gst.Caps) assert len(caps) == 2 - assert isinstance(caps[0], gst.Structure) - assert isinstance(caps[1], gst.Structure) - assert caps[0].get_name() == 'video/x-raw-yuv' - assert caps[1].get_name() == 'video/x-raw-rgb' - assert isinstance(caps[0]['width'], int) - assert isinstance(caps[1]['width'], int) - assert caps[0]['width'] == 10 - assert caps[1]['width'] == 20 + struct = caps[0] + assert isinstance(struct, gst.Structure), struct + assert struct.get_name() == 'video/x-raw-yuv', struct.get_name() + assert struct.has_key('width') + assert isinstance(struct['width'], int) + assert struct['width'] == 10 + struct = caps[1] + assert isinstance(struct, gst.Structure), struct + assert struct.get_name() == 'video/x-raw-rgb', struct.get_name() + assert struct.has_key('height') + assert isinstance(struct['height'], float) + assert struct['height'] == 20.0 def testCapsStructureChange(self): 'test if changing the structure of the caps works by reference' @@ -56,5 +60,16 @@ class CapsTest(unittest.TestCase): structure = self.caps[0] assert structure['width'] == 5.0 + def testCapsBadConstructor(self): + struct = gst.structure_from_string('video/x-raw-yuv,width=10') + self.assertRaises(TypeError, gst.Caps, None) + self.assertRaises(TypeError, gst.Caps, 1) + self.assertRaises(TypeError, gst.Caps, 2.0) + self.assertRaises(TypeError, gst.Caps, object) + self.assertRaises(TypeError, gst.Caps, 1, 2, 3) + + # This causes segfault! + #self.assertRaises(TypeError, gst.Caps, struct, 10, None) + if __name__ == "__main__": unittest.main() diff --git a/testsuite/test_struct.py b/testsuite/test_struct.py index 252056c504..e51e2b3b4d 100644 --- a/testsuite/test_struct.py +++ b/testsuite/test_struct.py @@ -5,6 +5,9 @@ class StructureTest(unittest.TestCase): def setUp(self): self.struct = gst.structure_from_string('video/x-raw-yuv,width=10,foo="bar",pixel-aspect-ratio=1/2,framerate=5.0') + #def foo(self): + # gst.structure_from_string("foo") + def testName(self): assert self.struct.get_name() == 'video/x-raw-yuv' self.struct.set_name('foobar')