mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
Implement sq_contains and add tests for gst.TagList.
Original commit message from CVS: * gst/gsttaglist.override (_wrap_gst_tag_list_contains): * testsuite/test_taglist.py (TestTagList.testKeys): Implement sq_contains and add tests for gst.TagList.
This commit is contained in:
parent
e8b581108d
commit
51baae336c
5 changed files with 76 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2007-03-17 Johan Dahlin <jdahlin@async.com.br>
|
||||
|
||||
* gst/gsttaglist.override (_wrap_gst_tag_list_contains):
|
||||
* testsuite/test_taglist.py (TestTagList.testKeys):
|
||||
|
||||
Implement sq_contains and add tests for TagList.
|
||||
|
||||
2007-03-02 Edward Hervey <edward@fluendo.com>
|
||||
|
||||
* gst/__init__.py:
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 9a56e28fc15440eb6852411321c46312e1d1bb73
|
||||
Subproject commit dec151d15512e4cca2dcdd36d9c6c4a2185760ec
|
|
@ -117,3 +117,25 @@ static PyMappingMethods _wrap_gst_tag_list_tp_as_mapping = {
|
|||
(binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */
|
||||
(objobjargproc)_wrap_gst_tag_list_ass_subscript /* mp_ass_subscript */
|
||||
};
|
||||
%%
|
||||
override-slot GstTagList.tp_as_sequence
|
||||
static int
|
||||
_wrap_gst_tag_list_contains(PyGObject *self, PyObject *py_key)
|
||||
{
|
||||
return gst_structure_has_field((GstStructure*)self->obj,
|
||||
PyString_AsString(py_key));
|
||||
}
|
||||
|
||||
static PySequenceMethods _wrap_gst_tag_list_tp_as_sequence = {
|
||||
(inquiry)NULL,
|
||||
(binaryfunc)NULL,
|
||||
(intargfunc)NULL,
|
||||
(intargfunc)NULL,
|
||||
(intintargfunc)NULL,
|
||||
(intobjargproc)NULL,
|
||||
(intintobjargproc)NULL,
|
||||
(objobjproc)_wrap_gst_tag_list_contains,
|
||||
(binaryfunc)NULL,
|
||||
(intargfunc)NULL,
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ tests = \
|
|||
test_registry.py \
|
||||
test_struct.py \
|
||||
test_segment.py \
|
||||
test_taglist.py \
|
||||
test_xml.py
|
||||
|
||||
check-local: testhelper.la
|
||||
|
|
45
testsuite/test_taglist.py
Normal file
45
testsuite/test_taglist.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# gst-python - Python bindings for GStreamer
|
||||
# Copyright (C) 2007 Johan Dahlin
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
from common import gst, TestCase
|
||||
|
||||
|
||||
class TestTagList(TestCase):
|
||||
def testContains(self):
|
||||
taglist = gst.TagList()
|
||||
self.failIf('key' in taglist)
|
||||
taglist['key'] = 'value'
|
||||
self.failUnless('key' in taglist)
|
||||
|
||||
def testLength(self):
|
||||
taglist = gst.TagList()
|
||||
self.assertEqual(len(taglist), 0)
|
||||
taglist['key1'] = 'value'
|
||||
taglist['key2'] = 'value'
|
||||
self.assertEqual(len(taglist), 2)
|
||||
|
||||
def testKeys(self):
|
||||
taglist = gst.TagList()
|
||||
self.assertEqual(taglist.keys(), [])
|
||||
taglist['key1'] = 'value'
|
||||
taglist['key2'] = 'value'
|
||||
keys = taglist.keys()
|
||||
keys.sort()
|
||||
self.assertEqual(keys, ['key1', 'key2'])
|
Loading…
Reference in a new issue