diff options
| author | Johan Dahlin <johan@src.gnome.org> | 2006-01-09 12:26:46 +0000 |
|---|---|---|
| committer | Johan Dahlin <johan@src.gnome.org> | 2006-01-09 12:26:46 +0000 |
| commit | 551a38178f7e66f215980fb01200472c8e6d3cd4 (patch) | |
| tree | fbbfd2556f77dc9f64c5c92af76a7dc35930f859 /tests | |
| parent | 0b07af909c44f27368a13ecfa94bfda5762e58fb (diff) | |
| download | pygobject-551a38178f7e66f215980fb01200472c8e6d3cd4.tar.gz pygobject-551a38178f7e66f215980fb01200472c8e6d3cd4.tar.xz pygobject-551a38178f7e66f215980fb01200472c8e6d3cd4.zip | |
Split out PyGObject from PyGTK.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile.am | 23 | ||||
| -rw-r--r-- | tests/common.py | 20 | ||||
| -rw-r--r-- | tests/leak.glade | 29 | ||||
| -rw-r--r-- | tests/runtests.py | 2 | ||||
| -rw-r--r-- | tests/test_actiongroup.py | 127 | ||||
| -rw-r--r-- | tests/test_dialog.py | 24 | ||||
| -rw-r--r-- | tests/test_gdk.py | 12 | ||||
| -rw-r--r-- | tests/test_gdkevent.py | 22 | ||||
| -rw-r--r-- | tests/test_glade.py | 33 | ||||
| -rw-r--r-- | tests/test_gtype.py | 8 | ||||
| -rw-r--r-- | tests/test_liststore.py | 24 | ||||
| -rw-r--r-- | tests/test_radiobutton.py | 98 | ||||
| -rw-r--r-- | tests/test_signal.py | 42 | ||||
| -rw-r--r-- | tests/test_subtype.py | 55 | ||||
| -rw-r--r-- | tests/test_textview.py | 14 | ||||
| -rw-r--r-- | tests/test_thread.py | 7 | ||||
| -rw-r--r-- | tests/testhelpermodule.c | 6 | ||||
| -rw-r--r-- | tests/testmodule.py | 22 |
18 files changed, 44 insertions, 524 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 15ee4f0..c13ca72 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,12 +1,9 @@ INCLUDES = \ $(PYTHON_INCLUDES) \ $(GLIB_CFLAGS) \ - $(PANGO_CFLAGS) \ - $(ATK_CFLAGS) \ - $(GTK_CFLAGS) \ -I$(top_srcdir)/gobject -EXTRA_DIST = $(tests) common.py runtests.py test-thread.h test-unknown.h testmodule.py leak.glade +EXTRA_DIST = $(tests) common.py runtests.py test-thread.h test-unknown.h noinst_LTLIBRARIES = testhelper.la linked_LIBS = testhelper.la @@ -19,35 +16,19 @@ testhelper_la_SOURCES = \ test-unknown.c tests = \ - test_glade.py \ - test_conversion.py \ - test_dialog.py \ - test_enum.py \ - test_gdk.py \ test_gtype.py \ test_mainloop.py \ - test_radiobutton.py \ test_properties.py \ test_signal.py \ test_subprocess.py \ test_subtype.py \ - test_gdkevent.py \ test_unknown.py \ - test_textview.py \ test_source.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) -check-local: $(top_srcdir)/gtk/__init__.py - @if test "$(top_builddir)" != "$(top_srcdir)"; then \ - cp $(top_srcdir)/gtk/__init__.py $(top_builddir)/gtk/__init__.py; \ - cp $(top_srcdir)/gtk/keysyms.py $(top_builddir)/gtk/keysyms.py; \ - fi +check-local: @$(PYTHON) $(srcdir)/runtests.py $(top_builddir) $(top_srcdir) - @if test "$(top_builddir)" != "$(top_srcdir)"; then \ - rm -f $(top_builddir)/gtk/__init__.py*; \ - rm -f $(top_builddir)/gtk/keysyms.py*; \ - fi @rm -fr *.pyc diff --git a/tests/common.py b/tests/common.py index e970461..627e281 100644 --- a/tests/common.py +++ b/tests/common.py @@ -7,27 +7,16 @@ def importModules(buildDir, srcDir): # ltihooks sys.path.insert(0, srcDir) - # atk, pango - sys.path.insert(0, buildDir) + import ltihooks + sys.path.remove(srcDir) + # gobject sys.path.insert(0, os.path.join(buildDir, 'gobject')) - # _gtk, keysyms, glade - sys.path.insert(0, os.path.join(buildDir, 'gtk')) # testhelper sys.path.insert(0, os.path.join(buildDir, 'tests')) sys.argv.append('--g-fatal-warnings') - import ltihooks gobject = importModule('gobject', buildDir, 'gobject/gobject.la') - atk = importModule('atk', buildDir) - pango = importModule('pango', buildDir) - gtk = importModule('gtk', buildDir, 'gtk') - gdk = importModule('gtk.gdk', buildDir, '_gdk.la') - try: - glade = importModule('gtk.glade', buildDir, 'glade.la') - except ImportError: - glade = None - testhelper = importModule('testhelper', '.') ltihooks.uninstall() @@ -52,8 +41,9 @@ def importModule(module, directory, name=None): try: obj = __import__(module, {}, {}, fromlist) - except ImportError: + except ImportError, e: print 'WARNING: %s could not be imported' % origName + print e return if hasattr(obj, '__file__'): diff --git a/tests/leak.glade b/tests/leak.glade deleted file mode 100644 index 50161c0..0000000 --- a/tests/leak.glade +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkWindow" id="window1"> - <property name="border_width">25</property> - <property name="visible">True</property> - <property name="title" translatable="yes">window1</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="focus_on_map">True</property> - <property name="urgency_hint">False</property> - <signal name="destroy" handler="on_window1_destroy" last_modification_time="Sun, 25 Sep 2005 14:22:00 GMT"/> - - <child> - <placeholder/> - </child> -</widget> - -</glade-interface> diff --git a/tests/runtests.py b/tests/runtests.py index 42f6a0c..3ae7185 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -21,7 +21,7 @@ else: common.importModules(buildDir=buildDir, srcDir=srcDir) -SKIP_FILES = ['common', 'runtests', 'testmodule'] +SKIP_FILES = ['common', 'runtests'] dir = os.path.split(os.path.abspath(__file__))[0] os.chdir(dir) diff --git a/tests/test_actiongroup.py b/tests/test_actiongroup.py deleted file mode 100644 index d7ceed1..0000000 --- a/tests/test_actiongroup.py +++ /dev/null @@ -1,127 +0,0 @@ -# Test for Bug #162874 - -import unittest -import sys -import gc - -from common import gtk, gobject - - -class ActionGroupTest(unittest.TestCase): - ui0 = '''<ui> - <menubar name="MenuBar"> - <menu action="File"> - <menuitem action="Quit"/> - </menu> - <menu action="Sound"> - <menuitem action="Mute"/> - </menu> - <menu action="RadioBand"> - <menuitem action="AM"/> - <menuitem action="FM"/> - <menuitem action="SSB"/> - </menu> - </menubar> - <toolbar name="Toolbar"> - <toolitem action="Quit"/> - <separator/> - <toolitem action="Mute"/> - <separator name="sep1"/> - <placeholder name="RadioBandItems"> - <toolitem action="AM"/> - <toolitem action="FM"/> - <toolitem action="SSB"/> - </placeholder> - </toolbar> - </ui>''' - - def build_gui(self): - # Create the toplevel window - window = gtk.Window() - vbox = gtk.VBox() - window.add(vbox) - - # Create a UIManager instance - uimanager = gtk.UIManager() - self.uimanager = uimanager - - # Create the base ActionGroup - actiongroup = gtk.ActionGroup('UIMergeExampleBase') - - actiongroup.add_actions([('File', None, '_File'), - ('Sound', None, '_Sound'), - ('RadioBand', None, '_Radio Band')]) - uimanager.insert_action_group(actiongroup, 0) - - # Create an ActionGroup - actiongroup0 = gtk.ActionGroup('UIMergeExample0') - - # Create a ToggleAction, etc. - actiongroup0.add_toggle_actions([('Mute', None, '_Mute', '<Control>m', - 'Mute the volume', self.cb)]) - - # Create actions - actiongroup0.add_actions([('Quit', gtk.STOCK_QUIT, '_Quit me!', None, - 'Quit the Program', self.cb)]) - - # Create some RadioActions - actiongroup0.add_radio_actions([('AM', None, '_AM', '<Control>a', - 'AM Radio', 0), - ('FM', None, '_FM', '<Control>f', - 'FM Radio', 1), - ('SSB', None, '_SSB', '<Control>b', - 'SSB Radio', 2), - ], 0, self.cb) - - # Add the actiongroup to the uimanager - uimanager.insert_action_group(actiongroup0, 1) - - self.ag0 = actiongroup0 - del actiongroup0 - - # Add a UI description - self.merge_id0 = uimanager.add_ui_from_string(self.ui0) - - # Create a MenuBar - menubar = uimanager.get_widget('/MenuBar') - vbox.pack_start(menubar, False) - - # Create a Toolbar - toolbar = uimanager.get_widget('/Toolbar') - vbox.pack_start(toolbar, False) - - gobject.timeout_add(50, self.timeout_cb) - - gtk.main() - return - - def timeout_cb(self): - ag0 = self.ag0 - uimanager = self.uimanager - del self.ag0, self.uimanager - - uimanager.remove_ui(self.merge_id0) - uimanager.remove_action_group(ag0) - - gc.collect() # Clean out unreachable objects - - del ag0 - assert gc.collect() == 1 # Collect just the ActionGroup - - uimanager.ensure_update() - assert gc.collect() == 6 # Now the GtkActions have lost their last - # GObject reference; they should be collected. - # We have a ToggleAction, an Action and a - # RadioAction, plus self.cb is bound in three - # closures. - - gtk.main_quit() - - def testActionGroups(self): - self.build_gui() - - def cb(self, action): - return - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_dialog.py b/tests/test_dialog.py deleted file mode 100644 index 7fc168d..0000000 --- a/tests/test_dialog.py +++ /dev/null @@ -1,24 +0,0 @@ -import sys -import unittest - -from common import gtk - -class MessageDialogTest(unittest.TestCase): - def testDialogAdd(self): - dialog = gtk.MessageDialog() - - response_id = sys.maxint + 1 - self.assertRaises(OverflowError, dialog.add_button, "Foo", response_id) - self.assertRaises(OverflowError, dialog.add_buttons, "Foo", response_id) - - def testSubclass(self): - # Normal subclassing should not register a type - sub = type('sub', (gtk.MessageDialog,), {}) - self.assertEqual(sub.__gtype__.name, 'GtkMessageDialog') - - # This depends on 311254 - #type('Sub', (gtk.MessageDialog,), {'__gtype_name__': 'SubDialog'}) - #self.assertEqual(sub.__gtype__.name, 'SubDialog') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_gdk.py b/tests/test_gdk.py deleted file mode 100644 index 7bbaf9a..0000000 --- a/tests/test_gdk.py +++ /dev/null @@ -1,12 +0,0 @@ -import unittest - -from common import gtk - -class GdkTest(unittest.TestCase): - def testBitmapCreateFromData(self): - gtk.gdk.bitmap_create_from_data(None, '\x00', 1, 1) - - def testPixmapCreateFromData(self): - black = gtk.gdk.color_parse('black') - gtk.gdk.pixmap_create_from_data(None, '\x00', 1, 1, 1, - black, black) diff --git a/tests/test_gdkevent.py b/tests/test_gdkevent.py deleted file mode 100644 index 9ba0613..0000000 --- a/tests/test_gdkevent.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- Mode: Python -*- - -import unittest - -from common import gtk - -class TestGdkEvent(unittest.TestCase): - def testWindowSetter(self): - event = gtk.gdk.Event(gtk.gdk.BUTTON_PRESS) - - win1 = gtk.Window() - win1.realize() - event.window = win1.window - self.assertEqual(event.window, win1.window) - - win2 = gtk.Window() - win2.realize() - event.window = win2.window - self.assertEqual(event.window, win2.window) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_glade.py b/tests/test_glade.py deleted file mode 100644 index ce9b99e..0000000 --- a/tests/test_glade.py +++ /dev/null @@ -1,33 +0,0 @@ -import unittest - -from common import gtk, gobject -import weakref -import gc - -class TestGlade(unittest.TestCase): - - class SimpleTest: - def __init__(self, test): - xml = gtk.glade.XML('leak.glade') - xml.signal_autoconnect(self) - self.test = test - self.window = xml.get_widget("window1") - self.window.destroy() - def on_window1_destroy(self, window): - gobject.idle_add(self.test.leak_check, weakref.ref(self), weakref.ref(self.window)) - - def leak_check(self, objref, windowref): - while gc.collect(): - pass - gtk.main_quit() - self.assertEqual(objref(), None) - self.windowref = windowref - - def testAutoconnectLeak(self): - self.SimpleTest(self) - gtk.main() - self.assertEqual(self.windowref(), None) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_gtype.py b/tests/test_gtype.py index eb89a87..b8177fd 100644 --- a/tests/test_gtype.py +++ b/tests/test_gtype.py @@ -1,7 +1,7 @@ import unittest from gobject import GType -from common import gobject, gtk +from common import gobject class GTypeTest(unittest.TestCase): def checkType(self, expected, *objects): @@ -23,9 +23,9 @@ class GTypeTest(unittest.TestCase): def testInt(self): self.checkType(gobject.TYPE_INT, 'gint', int) - model = gtk.ListStore(str, int) - iter = model.append() - model.set(iter, 1, 100000000) + # model = gtk.ListStore(str, int) + # iter = model.append() + # model.set(iter, 1, 100000000) def testInt64(self): self.checkType(gobject.TYPE_INT64, 'gint64') diff --git a/tests/test_liststore.py b/tests/test_liststore.py deleted file mode 100644 index a5d9f61..0000000 --- a/tests/test_liststore.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest - -from common import gtk - -class ListStoreTest(unittest.TestCase): - def testConstructor(self): - self.assertRaises(TypeError, gtk.ListStore) - - def testInsert(self): - store = gtk.ListStore(int) - - # Old way, with iters - store.set_value(store.insert(0), 0, 2) - self.assertEqual(len(store), 1) - self.assertEqual(store[0][0], 2) - - # New way - store.insert(0, (1,)) - self.assertEqual(len(store), 2) - self.assertEqual(store[0][0], 1) - self.assertEqual(store[1][0], 2) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_radiobutton.py b/tests/test_radiobutton.py deleted file mode 100644 index 98d86dd..0000000 --- a/tests/test_radiobutton.py +++ /dev/null @@ -1,98 +0,0 @@ -import unittest - -from common import gtk - -class RadioTest(unittest.TestCase): - widget_type = None - constructor_args = () - - def new(self): - return self.widget_type(*self.constructor_args) - - def newLabel(self, label): - return self.widget_type(None, label) - - def newGroup(self, group): - return self.widget_type(group) - - def getLabel(self, obj): - return obj.get_property('label') - - def compareGroups(self, group1, group2): - return self.assertEqual(group1, group2) - - def testCreate(self): - if self.widget_type is None: - return - radio = self.new() - self.assert_(isinstance(radio, self.widget_type)) - - def testLabel(self): - if self.widget_type is None: - return - radio = self.newLabel('test-radio') - self.assertEqual(self.getLabel(radio), 'test-radio') - - def testGroup(self): - if self.widget_type is None: - return - radio = self.new() - radio2 = self.newGroup(radio) - self.compareGroups(radio.get_group(), radio2.get_group()) - self.compareGroups(radio2.get_group(), radio.get_group()) - - def testEmptyGroup(self): - if self.widget_type is None: - return - radio = self.new() - radio2 = self.new() - self.compareGroups(radio.get_group(), [radio]) - self.compareGroups(radio2.get_group(), [radio2]) - radio2.set_group(radio) - self.compareGroups(radio.get_group(), radio2.get_group()) - self.compareGroups(radio2.get_group(), radio.get_group()) - radio2.set_group(None) - self.compareGroups(radio.get_group(), [radio]) - self.compareGroups(radio2.get_group(), [radio2]) - -class RadioButtonTest(RadioTest): - widget_type = gtk.RadioButton - -class RadioActionTest(RadioTest): - widget_type = gtk.RadioAction - constructor_args = ('RadioAction', 'test-radio-action', '', '', 0) - - def newGroup(self, radio): - # No constructor, so set it manually - obj = self.new() - obj.set_group(radio) - return obj - - def newLabel(self, label): - return gtk.RadioAction('RadioAction', label, '', '', 0) - -class RadioToolButtonTest(RadioTest): - widget_type = gtk.RadioToolButton - - def compareGroups(self, group1, group2): - # GtkRadioToolButton.set/get_groups return GtkRadioButtons, - # so instead of doing a normal cmp, compare ids - return cmp(map(id, group1), map(id, group2)) - - def newLabel(self, label): - # We don't have a constructor for which we can pass in a label - # for, so just call set_label instead - radio = gtk.RadioToolButton(None) - radio.set_label(label) - return radio - -class RadioMenuItem(RadioTest): - widget_type = gtk.RadioMenuItem - - def getLabel(self, obj): - # The label is stored in a gtk.AccelLabel, which is the only - # child of the RadioMenuItem. - return obj.get_child().get_text() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_signal.py b/tests/test_signal.py index 5513f2f..36014fc 100644 --- a/tests/test_signal.py +++ b/tests/test_signal.py @@ -3,7 +3,7 @@ import gc import unittest -from common import gobject, gtk +from common import gobject class C(gobject.GObject): __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, @@ -73,49 +73,9 @@ class TestGPropertyError(unittest.TestCase): self.assertRaises(TypeError, foo) gc.collect() - -class DrawingArea(gtk.DrawingArea): - __gsignals__ = { 'my-activate': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ()) , - 'my-adjust': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, - (gtk.Adjustment, gtk.Adjustment)) } - def __init__(self): - gtk.DrawingArea.__init__(self) - self.activated = False - self.adjusted = False - - def do_my_activate(self): - self.activated = True - - def do_my_adjust(self, hadj, vadj): - self.adjusted = True - -DrawingArea.set_activate_signal('my-activate') -DrawingArea.set_set_scroll_adjustments_signal('my-adjust') - -class TestOldStyleOverride(unittest.TestCase): - def testActivate(self): - b = DrawingArea() - self.assertEqual(b.activated, False) - b.activate() - self.assertEqual(b.activated, True) - - def testSetScrollAdjustment(self): - b = DrawingArea() - self.assertEqual(b.adjusted, False) - b.set_scroll_adjustments(gtk.Adjustment(), gtk.Adjustment()) - self.assertEqual(b.adjusted, True) - class TestList(unittest.TestCase): def testListObject(self): self.assertEqual(gobject.signal_list_names(C), ('my-signal',)) - def testListInterface(self): - signals = gobject.signal_list_names(gtk.Editable) - self.failUnless('changed' in signals) - self.failUnless('insert-text' in signals) - self.failUnless('delete-text' in signals) - if __name__ == '__main__': unittest.main() diff --git a/tests/test_subtype.py b/tests/test_subtype.py index 91a1e71..99fbb3b 100644 --- a/tests/test_subtype.py +++ b/tests/test_subtype.py @@ -1,7 +1,7 @@ import unittest import testmodule -from common import gobject, gtk, testhelper +from common import gobject, testhelper from gobject import GObject, GInterface class TestSubType(unittest.TestCase): @@ -9,28 +9,18 @@ class TestSubType(unittest.TestCase): t = type('testtype', (GObject, GInterface), {}) self.failUnless(issubclass(t, GObject)) self.failUnless(issubclass(t, GInterface)) - t = type('testtype2', (GObject, gtk.TreeModel), {}) - self.failUnless(issubclass(t, GObject)) - self.failUnless(issubclass(t, gtk.TreeModel)) - def testTpBasicSize(self): - self.assertEqual(GObject.__basicsize__, - gtk.Widget.__basicsize__) - - self.assertEqual(GInterface.__basicsize__, - gtk.TreeModel.__basicsize__) - - def testLabel(self): - label = gtk.Label() + def testGObject(self): + label = gobject.GObject() self.assertEqual(label.__grefcount__, 1) - label = gobject.new(gtk.Label) + label = gobject.new(gobject.GObject) self.assertEqual(label.__grefcount__, 1) def testPythonSubclass(self): - label = testmodule.PyLabel() + label = testmodule.PyGObject() self.assertEqual(label.__grefcount__, 1) self.assertEqual(label.props.label, "hello") - label = gobject.new(testmodule.PyLabel) + label = gobject.new(testmodule.PyGObject) self.assertEqual(label.__grefcount__, 1) self.assertEqual(label.props.label, "hello") @@ -40,39 +30,8 @@ class TestSubType(unittest.TestCase): refcount = testhelper.test_g_object_new() self.assertEqual(refcount, 2) - def testMassiveGtkSubclassing(self): - for name, cls in [(name, getattr(gtk, name)) for name in dir(gtk)]: - ## Skip some deprecated types - if name in ['CTree', '_gobject']: - continue - try: - if not issubclass(cls, gobject.GObject): - continue - except TypeError: # raised by issubclass if cls is not a class - continue - subname = name + "PyGtkTestSubclass" - sub = type(subname, (cls,), {'__gtype_name__': subname }) - - def testGtkWindowObjNewRefcount(self): - foo = gobject.new(gtk.Window) - self.assertEqual(foo.__grefcount__, 2) - - def testGtkWindowFactoryRefcount(self): - foo = gtk.Window() - self.assertEqual(foo.__grefcount__, 2) - - def testPyWindowObjNewRefcount(self): - PyWindow = type('PyWindow', (gtk.Window,), dict(__gtype_name__='PyWindow1')) - foo = gobject.new(PyWindow) - self.assertEqual(foo.__grefcount__, 2) - - def testGtkWindowFactoryRefcount(self): - PyWindow = type('PyWindow', (gtk.Window,), dict(__gtype_name__='PyWindow2')) - foo = PyWindow() - self.assertEqual(foo.__grefcount__, 2) - def testRegisterArgNotType(self): self.assertRaises(TypeError, gobject.type_register, 1) def testGObjectNewError(self): - self.assertRaises(TypeError, gobject.new, gtk.Label, text='foo') + self.assertRaises(TypeError, gobject.new, gobject.GObject, text='foo') diff --git a/tests/test_textview.py b/tests/test_textview.py deleted file mode 100644 index 5022fda..0000000 --- a/tests/test_textview.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys -import unittest - -from common import gtk - -class TextViewTest(unittest.TestCase): - def test_default_attributes(self): - textview = gtk.TextView() - attrs = textview.get_default_attributes() - textview.destroy() - self.assertEqual(attrs.font_scale, 1.0) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_thread.py b/tests/test_thread.py index 647783a..231930f 100644 --- a/tests/test_thread.py +++ b/tests/test_thread.py @@ -1,7 +1,8 @@ import os import unittest -from common import gobject, gtk, testhelper +from common import gobject, testhelper +main = gobject.MainLoop() class TestThread(unittest.TestCase): def from_thread_cb(self, test, enum): @@ -17,7 +18,7 @@ class TestThread(unittest.TestCase): def testExtensionModule(self): gobject.idle_add(self.idle_cb) gobject.timeout_add(50, self.timeout_cb) - gtk.main() + main.run() def timeout_cb(self): - gtk.main_quit() + main.quit() diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c index 7684721..b849344 100644 --- a/tests/testhelpermodule.c +++ b/tests/testhelpermodule.c @@ -15,9 +15,9 @@ test_type_get_type(void) GTypeInfo *type_info; GTypeQuery query; - parent_type = g_type_from_name("PyLabel"); + parent_type = g_type_from_name("PyGObject"); if (parent_type == 0) - g_error("could not get PyLabel from testmodule"); + g_error("could not get PyGObject from testmodule"); type_info = (GTypeInfo *)g_new0(GTypeInfo, 1); @@ -74,7 +74,7 @@ _wrap_test_g_object_new (PyObject * self) GObject *obj; PyObject *rv; - obj = g_object_new(g_type_from_name("PyLabel"), NULL); + obj = g_object_new(g_type_from_name("PyGObject"), NULL); rv = PyInt_FromLong(obj->ref_count); /* should be == 2 at this point */ g_object_unref(obj); return rv; diff --git a/tests/testmodule.py b/tests/testmodule.py index 8761ecf..2fda01f 100644 --- a/tests/testmodule.py +++ b/tests/testmodule.py @@ -1,9 +1,21 @@ import gobject -import gtk - -class PyLabel(gtk.Label): - __gtype_name__ = 'PyLabel' +class PyGObject(gobject.GObject): + __gtype_name__ = 'PyGObject' + __gproperties__ = { + 'label': (gobject.TYPE_STRING, + 'label property', + 'the label of the object', + 'default', gobject.PARAM_READWRITE), + } + def __init__(self): - gtk.Label.__init__(self, "hello") + self._props = {} + gobject.GObject.__init__(self) + self.set_property('label', 'hello') + def do_set_property(self, name, value): + self._props[name] = value + + def do_get_property(self, name): + return self._props[name] |
