summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2004-09-27 16:51:25 +0000
committerJohan Dahlin <johan@src.gnome.org>2004-09-27 16:51:25 +0000
commitf313fd015607e037d98e7dfb991fc74bf68d1177 (patch)
treed04ee31c848287fd2805a27b4417309f3a724ee4
parentb4205323655072faef3e0d86a219c374ef9535b3 (diff)
downloadpygobject-f313fd015607e037d98e7dfb991fc74bf68d1177.tar.gz
pygobject-f313fd015607e037d98e7dfb991fc74bf68d1177.tar.xz
pygobject-f313fd015607e037d98e7dfb991fc74bf68d1177.zip
Small c module to help testing
* tests/testhelper.c: Small c module to help testing * tests/test_subtype.py: tests for this, use testhelper here aswell
-rw-r--r--tests/Makefile.am23
-rw-r--r--tests/common.py2
-rw-r--r--tests/test_subtype.py19
-rw-r--r--tests/testhelpermodule.c23
4 files changed, 59 insertions, 8 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 151671b..8d59009 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,18 @@
+INCLUDES = \
+ $(PYTHON_INCLUDES) \
+ $(GLIB_CFLAGS) \
+ $(PANGO_CFLAGS) \
+ $(ATK_CFLAGS) \
+ -I$(top_srcdir)/gobject
+
+EXTRA_DIST = $(tests) common.py runtests.py
+
+noinst_LTLIBRARIES = testhelper.la
+linked_LIBS = testhelper.la
+
+testhelper_la_LDFLAGS = -module -avoid-version
+testhelper_la_SOURCES = testhelpermodule.c
+
tests = \
conversion.py \
enum.py \
@@ -5,12 +20,14 @@ tests = \
test_signal.py \
test_subtype.py
+# This is a hack to make sure a shared library is built
+testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES)
+ $(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS)
+
PYTHONPATH = $(top_builddir):$(top_builddir)/gobject:$(top_srcdir):$(top_srcdir)/gtk
-check-local: $(top_srcdir)/gtk/__init__.py
+check-local: testhelper.la $(top_srcdir)/gtk/__init__.py
@if ! test -e $(top_builddir)/gtk/__init__.py; then cp $(top_srcdir)/gtk/__init__.py $(top_builddir)/gtk/__init__.py; fi
@PYTHONPATH=$(PYTHONPATH) DIST_CHECK=1 $(PYTHON) $(srcdir)/runtests.py
@if test "$(top_builddir)" != "$(top_srcdir)"; then rm -f $(top_builddir)/gtk/__init__.py*; fi
@rm -fr *.pyc
-
-EXTRA_DIST = $(tests) common.py runtests.py
diff --git a/tests/common.py b/tests/common.py
index adf4bcc..cbb09e5 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -15,4 +15,6 @@ import gtk
from gtk import gdk
from gtk import glade
+import testhelper
+
ltihooks.uninstall()
diff --git a/tests/test_subtype.py b/tests/test_subtype.py
index 6a13b31..b2b5dcc 100644
--- a/tests/test_subtype.py
+++ b/tests/test_subtype.py
@@ -1,13 +1,22 @@
import unittest
-from common import gobject, gtk
+from common import gobject, gtk, testhelper
class TestSubType(unittest.TestCase):
def testSubType(self):
t = type('testtype', (gobject.GObject, gobject.GInterface), {})
- assert issubclass(t, gobject.GObject)
- assert issubclass(t, gobject.GInterface)
+ self.assert_(issubclass(t, gobject.GObject))
+ self.assert_(issubclass(t, gobject.GInterface))
t = type('testtype2', (gobject.GObject, gtk.TreeModel), {})
- assert issubclass(t, gobject.GObject)
- assert issubclass(t, gtk.TreeModel)
+ self.assert_(issubclass(t, gobject.GObject))
+ self.assert_(issubclass(t, gtk.TreeModel))
+
+ def testTpBasicSize(self):
+ iface = testhelper.get_tp_basicsize(gobject.GInterface)
+ gobj = testhelper.get_tp_basicsize(gobject.GObject)
+ widget = testhelper.get_tp_basicsize(gtk.Widget)
+ self.assert_(gobj == widget)
+
+ treemodel = testhelper.get_tp_basicsize(gtk.TreeModel)
+ self.assert_(iface == treemodel)
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
new file mode 100644
index 0000000..6b6a914
--- /dev/null
+++ b/tests/testhelpermodule.c
@@ -0,0 +1,23 @@
+#include "pygobject.h"
+
+PyObject *
+_wrap_get_tp_basicsize (PyObject * self,
+ PyObject * args)
+{
+ PyObject *item;
+ item = PyTuple_GetItem(args, 0);
+
+ return PyInt_FromLong(((PyTypeObject*)item)->tp_basicsize);
+}
+
+static PyMethodDef testhelper_methods[] = {
+ { "get_tp_basicsize", _wrap_get_tp_basicsize, METH_VARARGS },
+ { NULL, NULL }
+};
+
+void
+inittesthelper ()
+{
+ Py_InitModule ("testhelper", testhelper_methods);
+}
+