summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/Makefile.in14
-rw-r--r--tests/test_everything.py50
-rw-r--r--tests/test_gi.py16
-rw-r--r--tests/test_gobject.py4
-rw-r--r--tests/test_properties.py2
-rw-r--r--tests/test_signal.py2
-rw-r--r--tests/test_source.py45
8 files changed, 122 insertions, 25 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a7b0323..d69bbad 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -54,7 +54,7 @@ CLEANFILES += Regress-1.0.gir Regress-1.0.typelib GIMarshallingTests-1.0.gir GIM
check_LTLIBRARIES += testhelper.la
-testhelper_la_CFLAGS = -I$(top_srcdir)/gi/_gobject -I$(top_srcdir)/gi/_glib $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
+testhelper_la_CFLAGS = -I$(top_srcdir)/gi $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
testhelper_la_LDFLAGS = -module -avoid-version
testhelper_la_LIBADD = $(GLIB_LIBS)
testhelper_la_SOURCES = \
@@ -134,12 +134,6 @@ RUN_TESTS_ENV_VARS= \
# pygtkcompat tests need to be run in a separate process as they
# clobber global name space
check-local: $(check_LTLIBRARIES:.la=.so) $(test_typelibs) gschemas.compiled
- @echo " CHECK Pyflakes"
- @if type pyflakes >/dev/null 2>&1; then pyflakes $(top_srcdir); else echo "skipped, pyflakes not installed"; fi
- @if test -z "$$SKIP_PEP8"; then \
- echo " CHECK PEP8"; \
- if type pep8 >/dev/null 2>&1; then pep8 --ignore=E501,E123,E124 --repeat --show-source $(top_srcdir); else echo "skipped, pep8 not installed"; fi; \
- fi
export `$(DBUS_LAUNCH)` && \
$(RUN_TESTS_ENV_VARS) $(EXEC_NAME) $(PYTHON) -Wd $(srcdir)/runtests.py; rc=$$?; \
[ "$$rc" -ne 0 ] || [ -n "$$TEST_NAMES" ] || { TEST_NAMES=compat_test_pygtk $(RUN_TESTS_ENV_VARS) $(EXEC_NAME) $(PYTHON) -Wd -Werror::PendingDeprecationWarning -Werror::DeprecationWarning -Werror::RuntimeWarning $(srcdir)/runtests.py; rc=$$?; }; \
@@ -153,12 +147,12 @@ check.nemiver:
EXEC_NAME="nemiver" $(MAKE) check
check.valgrind:
- EXEC_NAME="G_SLICE=always-malloc valgrind --leak-check=full --show-possibly-lost=no --suppressions=python.supp" G_DEBUG=gc-friendly $(MAKE) check
+ EXEC_NAME="G_SLICE=always-malloc valgrind --leak-check=full --show-possibly-lost=no --suppressions=$(top_srcdir)/tests/$(PYTHON_BASENAME).supp" G_DEBUG=gc-friendly $(MAKE) check
check.valgrindlog:
mkdir -p $(top_builddir)/tmp
- EXEC_NAME="G_SLICE=always-malloc valgrind --log-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.log --leak-check=full --show-possibly-lost=no --suppressions=python.supp" G_DEBUG=gc-friendly $(MAKE) check
+ EXEC_NAME="G_SLICE=always-malloc valgrind --log-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.log --leak-check=full --show-possibly-lost=no --suppressions=$(top_srcdir)/tests/$(PYTHON_BASENAME).supp" G_DEBUG=gc-friendly $(MAKE) check
check.valgrindxml:
mkdir -p $(top_builddir)/tmp
- EXEC_NAME="G_SLICE=always-malloc valgrind --xml=yes --xml-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.xml --leak-check=full --show-possibly-lost=no --suppressions=python.supp" G_DEBUG=gc-friendly $(MAKE) check
+ EXEC_NAME="G_SLICE=always-malloc valgrind --xml=yes --xml-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.xml --leak-check=full --show-possibly-lost=no --suppressions=$(top_srcdir)/tests/$(PYTHON_BASENAME).supp" G_DEBUG=gc-friendly $(MAKE) check
diff --git a/tests/Makefile.in b/tests/Makefile.in
index b034f67..d5b1610 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -311,7 +311,7 @@ libgimarshallingtests_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS)
@ENABLE_CAIRO_TRUE@nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
@ENABLE_CAIRO_TRUE@libregress_la_CFLAGS = $(GIO_CFLAGS) $(CAIRO_CFLAGS)
@ENABLE_CAIRO_TRUE@libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(CAIRO_LIBS)
-testhelper_la_CFLAGS = -I$(top_srcdir)/gi/_gobject -I$(top_srcdir)/gi/_glib $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
+testhelper_la_CFLAGS = -I$(top_srcdir)/gi $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
testhelper_la_LDFLAGS = -module -avoid-version
testhelper_la_LIBADD = $(GLIB_LIBS)
testhelper_la_SOURCES = \
@@ -757,12 +757,6 @@ clean-local:
# pygtkcompat tests need to be run in a separate process as they
# clobber global name space
check-local: $(check_LTLIBRARIES:.la=.so) $(test_typelibs) gschemas.compiled
- @echo " CHECK Pyflakes"
- @if type pyflakes >/dev/null 2>&1; then pyflakes $(top_srcdir); else echo "skipped, pyflakes not installed"; fi
- @if test -z "$$SKIP_PEP8"; then \
- echo " CHECK PEP8"; \
- if type pep8 >/dev/null 2>&1; then pep8 --ignore=E501,E123,E124 --repeat --show-source $(top_srcdir); else echo "skipped, pep8 not installed"; fi; \
- fi
export `$(DBUS_LAUNCH)` && \
$(RUN_TESTS_ENV_VARS) $(EXEC_NAME) $(PYTHON) -Wd $(srcdir)/runtests.py; rc=$$?; \
[ "$$rc" -ne 0 ] || [ -n "$$TEST_NAMES" ] || { TEST_NAMES=compat_test_pygtk $(RUN_TESTS_ENV_VARS) $(EXEC_NAME) $(PYTHON) -Wd -Werror::PendingDeprecationWarning -Werror::DeprecationWarning -Werror::RuntimeWarning $(srcdir)/runtests.py; rc=$$?; }; \
@@ -776,15 +770,15 @@ check.nemiver:
EXEC_NAME="nemiver" $(MAKE) check
check.valgrind:
- EXEC_NAME="G_SLICE=always-malloc valgrind --leak-check=full --show-possibly-lost=no --suppressions=python.supp" G_DEBUG=gc-friendly $(MAKE) check
+ EXEC_NAME="G_SLICE=always-malloc valgrind --leak-check=full --show-possibly-lost=no --suppressions=$(top_srcdir)/tests/$(PYTHON_BASENAME).supp" G_DEBUG=gc-friendly $(MAKE) check
check.valgrindlog:
mkdir -p $(top_builddir)/tmp
- EXEC_NAME="G_SLICE=always-malloc valgrind --log-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.log --leak-check=full --show-possibly-lost=no --suppressions=python.supp" G_DEBUG=gc-friendly $(MAKE) check
+ EXEC_NAME="G_SLICE=always-malloc valgrind --log-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.log --leak-check=full --show-possibly-lost=no --suppressions=$(top_srcdir)/tests/$(PYTHON_BASENAME).supp" G_DEBUG=gc-friendly $(MAKE) check
check.valgrindxml:
mkdir -p $(top_builddir)/tmp
- EXEC_NAME="G_SLICE=always-malloc valgrind --xml=yes --xml-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.xml --leak-check=full --show-possibly-lost=no --suppressions=python.supp" G_DEBUG=gc-friendly $(MAKE) check
+ EXEC_NAME="G_SLICE=always-malloc valgrind --xml=yes --xml-file=$(top_builddir)/tmp/`git rev-parse HEAD | cut -c1-8`-$$TEST_NAMES.xml --leak-check=full --show-possibly-lost=no --suppressions=$(top_srcdir)/tests/$(PYTHON_BASENAME).supp" G_DEBUG=gc-friendly $(MAKE) check
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 61b40e1..0cd1804 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -761,6 +761,54 @@ class TestCallbacks(unittest.TestCase):
self.assertEqual(TestCallbacks.called, 10)
self.assertSequenceEqual(collected_user_data, [1, 2] * 10)
+ def test_callback_user_data_middle_none(self):
+ cb_info = {}
+
+ def callback(userdata):
+ cb_info['called'] = True
+ cb_info['userdata'] = userdata
+ return 1
+
+ (y, z, q) = Everything.test_torture_signature_2(
+ 42, callback, None, 'some string', 3)
+ self.assertEqual(y, 42)
+ self.assertEqual(z, 84)
+ self.assertEqual(q, 14)
+ self.assertTrue(cb_info['called'])
+ self.assertEqual(cb_info['userdata'], None)
+
+ def test_callback_user_data_middle_single(self):
+ cb_info = {}
+
+ def callback(userdata):
+ cb_info['called'] = True
+ cb_info['userdata'] = userdata
+ return 1
+
+ (y, z, q) = Everything.test_torture_signature_2(
+ 42, callback, 'User Data', 'some string', 3)
+ self.assertEqual(y, 42)
+ self.assertEqual(z, 84)
+ self.assertEqual(q, 14)
+ self.assertTrue(cb_info['called'])
+ self.assertEqual(cb_info['userdata'], 'User Data')
+
+ def test_callback_user_data_middle_tuple(self):
+ cb_info = {}
+
+ def callback(userdata):
+ cb_info['called'] = True
+ cb_info['userdata'] = userdata
+ return 1
+
+ (y, z, q) = Everything.test_torture_signature_2(
+ 42, callback, (-5, 'User Data'), 'some string', 3)
+ self.assertEqual(y, 42)
+ self.assertEqual(z, 84)
+ self.assertEqual(q, 14)
+ self.assertTrue(cb_info['called'])
+ self.assertEqual(cb_info['userdata'], (-5, 'User Data'))
+
def test_async_ready_callback(self):
TestCallbacks.called = False
TestCallbacks.main_loop = GLib.MainLoop()
@@ -1138,7 +1186,7 @@ class TestTortureProfile(unittest.TestCase):
sys.stdout.write("\ttorture test 4 (10000 iterations): ")
def callback(userdata):
- pass
+ return 0
userdata = [1, 2, 3, 4]
start_time = time.clock()
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 2411a49..2a6cc3d 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2266,6 +2266,20 @@ class TestPythonGObject(unittest.TestCase):
obj = self.ErrorObject()
self.assertEqual(obj.vfunc_return_value_only(), 0)
+ @unittest.skipUnless(hasattr(GIMarshallingTests, 'callback_owned_boxed'),
+ 'requires newer version of GI')
+ @unittest.expectedFailure # bug 722899
+ def test_callback_owned_box(self):
+ def callback(box, data):
+ self.box = box
+
+ def nop_callback(box, data):
+ pass
+
+ GIMarshallingTests.callback_owned_boxed(callback, None)
+ GIMarshallingTests.callback_owned_boxed(nop_callback, None)
+ self.assertEqual(self.box.long_, 1)
+
class TestMultiOutputArgs(unittest.TestCase):
@@ -2406,7 +2420,7 @@ class TestMRO(unittest.TestCase):
pass
expected = (E, D, B, C, A, GIMarshallingTests.Object,
- GObject.Object, GObject.Object.__base__, gi._gobject.GObject,
+ GObject.Object, GObject.Object.__base__, gi._gi._gobject.GObject,
object)
self.assertEqual(expected, E.__mro__)
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index d49011f..a88a4bc 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -8,7 +8,9 @@ import warnings
from gi.repository import GObject, GLib
from gi import PyGIDeprecationWarning
from gi.module import get_introspection_module
-from gi._gobject import _gobject
+
+import gi
+_gobject = gi._gi._gobject
import testhelper
diff --git a/tests/test_properties.py b/tests/test_properties.py
index ef6b867..d7ceb89 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -23,7 +23,7 @@ from gi.repository import Gio
from gi.repository import GLib
from gi.repository import Regress
from gi.repository import GIMarshallingTests
-from gi._gobject import propertyhelper
+from gi import _propertyhelper as propertyhelper
if sys.version_info < (3, 0):
TEST_UTF8 = "\xe2\x99\xa5"
diff --git a/tests/test_signal.py b/tests/test_signal.py
index e90264a..429afc9 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -5,7 +5,7 @@ import unittest
import sys
from gi.repository import GObject, GLib
-from gi._gobject import signalhelper
+from gi import _signalhelper as signalhelper
import testhelper
from compathelper import _long
diff --git a/tests/test_source.py b/tests/test_source.py
index 6f69927..e0910f9 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -220,6 +220,51 @@ class TestSource(unittest.TestCase):
del source
self.assertTrue(self.finalized)
+ @unittest.skip('https://bugzilla.gnome.org/show_bug.cgi?id=722387')
+ def test_python_unref_with_active_source(self):
+ # Tests a Python derived Source which is free'd in the context of
+ # Python, but remains active in the MainContext (via source.attach())
+ self.dispatched = False
+ self.finalized = False
+
+ class S(GLib.Source):
+ def prepare(s):
+ return (True, 1)
+
+ def check(s):
+ pass
+
+ def dispatch(s, callback, args):
+ self.dispatched = True
+ return False
+
+ def finalize(s):
+ self.finalized = True
+
+ source = S()
+ id = source.attach()
+ self.assertFalse(self.finalized)
+ self.assertFalse(source.is_destroyed())
+
+ # Delete the source from Python but should still remain
+ # active in the main context.
+ del source
+
+ context = GLib.MainContext.default()
+ while context.iteration(may_block=False):
+ pass
+
+ self.assertTrue(self.dispatched)
+ self.assertFalse(self.finalized)
+
+ source = context.find_source_by_id(id)
+ source.destroy() # Remove from main context.
+ self.assertTrue(source.is_destroyed())
+
+ # Source should be finalized called after del
+ del source
+ self.assertTrue(self.finalized)
+
def test_extra_init_args(self):
class SourceWithInitArgs(GLib.Source):
def __init__(self, arg, kwarg=None):