summaryrefslogtreecommitdiff
path: root/tests/test_source.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove all Python 2 Python codeChristoph Reiter2020-04-151-2/+0
|
* tests: remove some leftover debug printChristoph Reiter2018-08-151-2/+1
|
* pypy: one more gc.collect()Christoph Reiter2018-04-221-0/+1
|
* Destroy custom GLib.Source instances when they get freed. See #193Christoph Reiter2018-04-191-16/+8
| | | | | | | | | | | | When we create a custom GLib.Source instance and attach it to a MainContext the methods will be called by the context. In case the Python wrapper gets freed this means the object used in the callbacks is no longer valid and things crash. To prevent this case simply destroy the source in case it gets deallocated so that its methods will no longer be called after that. This means the user has to make sure that the object stays alive, like now, but without having crashes if one doesn't.
* test_source: add some gc.collect()Christoph Reiter2018-04-011-0/+5
|
* Revert "Revert "Revert "Refactor boxed wrapper memory management strategy"""Mathieu Duponchelle2018-02-161-6/+2
| | | | This reverts commit a506d5e3c64321c43a4ce7c2a72ca8d36e985999.
* Revert "Revert "Refactor boxed wrapper memory management strategy""Christoph Reiter2018-02-131-2/+6
| | | | This reverts commit daefdfa3e4dc97b4ae38250358d722f09764cc9b.
* tests: Make it possible to use pytest directlywip/creiter/pytest-directChristoph Reiter2018-02-121-5/+3
| | | | | | | | | | | pytest will just import the files passed to it and try to run tests. Since we need to run some setup code convert the tests directory to a Python package and do the initialization in __init__.py. This makes the init code (env vars, typelib search path, dbus) always run when something from the package gets imported. python3 setup.py build_tests # build pygobject and tests py.test-3 tests/test_gi.py # run tests in test_gi.py only
* Revert "Refactor boxed wrapper memory management strategy"Mathieu Duponchelle2018-01-231-6/+2
| | | | This reverts commit 85175047e66dfc0c0263eac91d8056a95d0a60a0.
* tests: Reduce usage of timeout_add() and sleep()Christoph Reiter2017-03-271-5/+5
| | | | | | | | | | * Instead of waiting for a fixed time, use a timeout and stop the main loop right after the test has succeeded. * Replace time.sleep to sync processes with os.pipe communication * Chain idle sources instead of using multiple timeout sources * Replace sleeps with unbufferd communication https://bugzilla.gnome.org/show_bug.cgi?id=698548
* tests: Make test suite run on macOSChristoph Reiter2017-03-241-0/+3
| | | | | | | * Skip all tests which fail, crash or hang. * Disable D-Bus in case dbus-run-session is not available. https://bugzilla.gnome.org/show_bug.cgi?id=780396
* tests: Silence various error messages and warnings.Christoph Reiter2015-07-021-4/+4
| | | | | | | | | | | | | | This silences glib warnings which are due to testing of error handling, deprecation warnings which we ignore since we want to continue testing deprecated code and other error output of code which is supposed to fail. To reduce code duplication and make things easier this introduces a shared helper module containing various context managers and decorators which allow testing and silencing of warnings and errors. https://bugzilla.gnome.org/show_bug.cgi?id=751156
* tests: Don't use deprecated override attributesChristoph Reiter2015-03-031-4/+4
| | | | | | | | | | | In case the test explicitly tests the deprecated attribute silence the resulting warnings. Instead of replacing GObject.PARAM_READWRITE with GObject.ParamFlags.READWRITE use (READABLE | WRITABLE) to not depend on a newer glib version. https://bugzilla.gnome.org/show_bug.cgi?id=743514
* Refactor boxed wrapper memory management strategySimon Feltman2014-08-171-2/+6
| | | | | | | | | | | | | | | | Change pygi_boxed_new() to accept "copy_boxed" instead of "free_on_dealloc". This changes memory management so the PyGIBoxed wrapper owns the boxed pointer given to it. Use __del__ instead of dealloc for freeing the boxed memory. This is needed for edge cases where objects like GSource can trigger the finalized callback during de-alloc, resulting in the PyObjects references counts being manipulated and triggering a re-entrant de-alloc. Add hack to keep Gtk.TreeIter.do_iter_next/previous implementations working which rely on pass-by-reference. See also: https://bugzilla.gnome.org/show_bug.cgi?id=734465 https://bugzilla.gnome.org/show_bug.cgi?id=722899 https://bugzilla.gnome.org/show_bug.cgi?id=726999
* tests: Add skipped test for GLib.Source inheritance problemsSimon Feltman2014-01-161-0/+45
| | | | | | Add test showing memory problems with sub-classes of GLib.Source. https://bugzilla.gnome.org/show_bug.cgi?id=722387
* tests: Fix source testing to handle critical with non-existing sourcesSimon Feltman2013-10-271-6/+12
| | | | | | | | Silence new critical coming from g_source_remove on non-existing sources. This function still returns False, but we need to silence the new critical so the test suite doesn't fail. See bug 710724. https://bugzilla.gnome.org/show_bug.cgi?id=710978
* Fix GLib.Source sub-classing with initializer argsSimon Feltman2013-09-111-0/+11
| | | | | | | Add variable args and keyword args to the GLib.Source.__new__ method to support sub-classes which want to implement __init__. https://bugzilla.gnome.org/show_bug.cgi?id=707904
* Fix GLib.Source ref leak upon destructionMartin Pitt2013-03-011-0/+31
| | | | | | | | In GLib.Source.__del__(), manually unref the source if we are a custom Source. As we use a static binding to create it, the GI part won't unref it for us, leading to finalize() method not being called and the GSource object leaking. https://bugzilla.gnome.org/show_bug.cgi?id=510511
* Restore actual GLib API after previous fixMartin Pitt2012-11-031-0/+30
| | | | | | | | | Re-fix the acceptance of priority as first argument for idle_add(), io_add_watch() and timeout_add(), as that is the real GLib API. Ensure that this keeps supporting the backwards compatible API with supplying multiple user data arguments. https://bugzilla.gnome.org/show_bug.cgi?id=687047
* Use a custom deprecation warning to make them visible by defaultMartin Pitt2012-10-261-1/+2
| | | | | | DeprecationWarning is not shown by default, and is thus rather useless for developers. Use a custom PyGIDeprecationWarning class and derive it from RuntimeWarning to make it visible.
* Drop static IO_* constantsMartin Pitt2012-10-241-1/+1
| | | | | | | Use the introspected constants instead, which are identical. Add backwards compatible aliases. These constants are covered by tests/test_iochannel.py.
* Remove static idle_add/timeout_add bindingsMartin Pitt2012-10-241-0/+19
| | | | | | Use the GLib functions through GI instead. Add overrides to ensure that default arguments continue to work as before, and that callbacks are called without an userdata argument if it wasn't specified.
* Add tests for priority argument of idle_add/timeout_addMartin Pitt2012-10-241-4/+59
| | | | | | | | | There is a potential to treat the priority as user data in a call like "GLib.idle_add(cb, GLib.PRIORITY_HIGH)". The current static bindings force using a keyword argument for the priority (but silently ignore it if you specify both userdata and priority as a positional argument). Test the correct handling of priority as well.
* Fix PEP-8 whitespace in previous commitMartin Pitt2012-10-241-0/+4
|
* Add tests for idle_add()/timeout_add with and without user dataMartin Pitt2012-10-241-0/+35
| | | | | This is implicitly spread over various test cases, but let's test it explicitly to ensure that the behaviour stays consistent when moving this to GI.
* tests: consitent naming styleMartin Pitt2012-10-241-12/+11
| | | | | Stop mixing camel case and underline naming, use the latter consistently in all tests.
* Mark GLib.Source.get_current_time() as deprecatedMartin Pitt2012-10-241-1/+7
| | | | | This method has been deprecated in GLib long ago. We have a workaround implementation using GLib.get_real_time(), but eventually this should go away.
* Remove static MainLoop, MainContext, and some GSource bindingsMartin Pitt2012-10-241-3/+0
| | | | | | | | | | | | | | | | | | glib's MainLoop and MainContext are fully introspectable these days, so remove our static bindings. This reduces our code, as well enables GLib API which hasn't been available through the static bindings before. This also requires dropping our custom static types for GLib Source, Timeout, and Idle. The latter two work fine with introspection and just need tiny overrides for a backwards compatible API. g_source_new() is not introspectable, though, so we need to keep our static wrappers for that. Move them from gi/_glib/pygsource.c to gi/pygi-source.c, so that it can use the GI API. Note that gi/_glib/pygsource.[hc] is still required for the static PollFD type which is used by the static IOChannel binding. Once the latter goes away, PollFD can be dropped as well. https://bugzilla.gnome.org/show_bug.cgi?id=686443
* Add some MainLoop, MainContext, and Source test casesMartin Pitt2012-10-231-0/+44
| | | | | | | These cover the remaining static API and behaviour, so that we have good regression tests for converting them to GI. See https://bugzilla.gnome.org/show_bug.cgi?id=686443
* Fix OverflowError in source_remove()Martin Pitt2012-10-231-1/+12
| | | | | | GSource IDs are unsigned, so we must use 'I' for parsing then, not 'i'. https://bugzilla.gnome.org/show_bug.cgi?id=684526
* Fix TestSource.testSources() test caseMartin Pitt2012-10-231-1/+7
| | | | | | | | | | | | | | | | | PyGObject has established the assumption that the destruction of a GLib.Source Python object does not destroy the actual GSource, as shown in TestSource.setup_timeout(), TestTimeout.test504337(), and https://bugzilla.gnome.org/show_bug.cgi?id=504337. So we need to explicitly destroy our MySource and Idle objects after using them, as their callbacks always return True and we do not want them to spill over into other tests. Also fix the assertions to actually verify that MySources' callback was callied (pos > 0, not pos >= 0), and use the unittest comparison API instead of a simple assert statement. https://bugzilla.gnome.org/show_bug.cgi?id=686627
* Wrap GLib.Source.is_destroyed() methodMartin Pitt2012-04-041-0/+24
| | | | | | Based on original patch from Bryan Silverthorn. https://bugzilla.gnome.org/show_bug.cgi?id=524719
* PEP8: run via --fix from craigds forkJohan Dahlin2012-03-221-0/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=672627
* Correct pyflakes warnings/errorsJohan Dahlin2012-03-211-3/+3
| | | | | | And add a target to make check that runs pyflakes. https://bugzilla.gnome.org/show_bug.cgi?id=672578
* fix tests to use the new GLib moduleJohn (J5) Palmieri2011-08-111-13/+11
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=642048
* refactor tests to only use PyGObject 3 syntaxJohn (J5) Palmieri2011-08-111-2/+3
| | | | | | | | | | | * for PyGObject 3 we want to discourage the use of legacy interfaces * Using interfaces like from gi.repository import GObject makes sure that the internal _gobject module is loaded and not PyGObject 2's gobject module which would cause the application to not work correctly https://bugzilla.gnome.org/show_bug.cgi?id=642048
* fix up tests so they run in py3kJohn (J5) Palmieri2010-09-011-2/+2
| | | | | | | | | * add a compat helper that should only be used by tests * fix long notation to use the compat helper instead * add parens to print statements * use compatable try/except pattern https://bugzilla.gnome.org/show_bug.cgi?id=615872
* Clean and improve the test infrastructureSimon van der Linden2010-07-291-2/+2
| | | | | | | | | To run select tests, use for instance: % make check TEST_NAMES='test_everything test_gi.TestConstant' It works with check.gdb and check.valgrind too. https://bugzilla.gnome.org/show_bug.cgi?id=625488
* Run pyflakes on the testsuite, remove unused imports and reorganizeJohan Dahlin2008-07-261-5/+4
| | | | | | | | | | | | | | | | | | | | 2008-07-26 Johan Dahlin <johan@gnome.org> * tests/common.py: * tests/test_conversion.py: * tests/test_enum.py: * tests/test_interface.py: * tests/test_option.py: * tests/test_source.py: * tests/test_subprocess.py: * tests/test_subtype.py: * tests/test_thread.py: * tests/test_unknown.py: Run pyflakes on the testsuite, remove unused imports and reorganize others. svn path=/trunk/; revision=859
* Move over glib constants to gobjectJohan Dahlin2008-07-261-11/+11
| | | | | | | | | | | | | | | | | | 2008-07-26 Johan Dahlin <johan@gnome.org> * glib/glibmodule.c (pyglib_register_constants), (init_glib): * gobject/__init__.py: * gobject/gobjectmodule.c (init_gobject): Move over glib constants to gobject * tests/test_gio.py: * tests/test_mainloop.py: * tests/test_source.py: * tests/test_subprocess.py: * tests/test_thread.py: Update tests to refer to glib when appropriate svn path=/trunk/; revision=858
* Bug 504337 - crash bug in gobject.Timeout and gobject.IdleJohan Dahlin2008-07-141-0/+7
| | | | | | | | | | | | | 2008-07-14 Johan Dahlin <johan@gnome.org> Bug 504337 - crash bug in gobject.Timeout and gobject.Idle * gobject/pygsource.c: * tests/test_source.py: Fix crash in Timeout and Idle, patch by Bryan Silverthorn. svn path=/trunk/; revision=799
* Unbreak Source.prepare (#523075, Bryan Silverthorn)Johan Dahlin2008-04-081-0/+28
| | | | | | | | | | | 2008-04-08 Johan Dahlin <jdahlin@async.com.br> * gobject/pygsource.c: * tests/test_source.py: Unbreak Source.prepare (#523075, Bryan Silverthorn) svn path=/trunk/; revision=766
* gobject/pygobject-private.h gobject/gobjectmodule.c gobject/Makefile.amManish Singh2005-07-101-0/+66
* gobject/pygobject-private.h * gobject/gobjectmodule.c * gobject/Makefile.am * gobject/pygsource.c: GSource wrapper, allows for pure python GSource implementations, as well as objectifying Idle and Timeout sources. * tests/Makefile.am * tests/test_source.py: Add test for the above. * gobject/gobjectmodule.c: timeout_add should take an explicit unsigned value. Also wrap g_get_current_time and g_main_depth. * gobject/pygiochannel.c (py_io_channel_write_chars): fix thread unblock/block logic.