summaryrefslogtreecommitdiff
path: root/tests/test_gi.py
Commit message (Collapse)AuthorAgeFilesLines
* tests: Remove PyPy fixme that appears to be workingBenjamin Berg2022-03-281-1/+0
| | | | | The test_gvalue_gobject_ref_counts appears to be working just fine these days.
* gi: Fix GArray length calculation for other item sizesBenjamin Berg2022-03-281-1/+0
|
* Fix some broken links to the PyPy bug trackerChristoph Reiter2022-03-271-1/+1
| | | | They moved away from bitbucket some time ago.
* Fix regression in marshalling partial() objectsChristoph Reiter2021-03-301-0/+16
| | | | | | | | | | | | In a4880dbc4575fadc0e3 a special case for partial() was added to handle gtk4 template callbacks. This in turn broken normal usage of partial objects. To work around that add a special marker in the gtk template code for now until we find a better fix. Also adds a test so this doesn't happen again. Fixes #464
* tests: fix test with glib 2.68 re GLocalFileChristoph Reiter2021-03-301-1/+1
| | | | | | | Since 2.68 Gio.File.new_for_path("") returns a GDummyFile instead of a GLocalFile. We don't really care since we just want to test that there is a name despite the type not being in the gir, so just pass a potentially valid path instead.
* tests: Remove usage of some deprecated unittest methodsChristoph Reiter2020-11-071-18/+18
|
* Remove all Python 2 Python codeChristoph Reiter2020-04-151-91/+38
|
* basic: allow None for boolean parametersChristoph Reiter2019-01-191-0/+5
| | | | | It already allows everything which can be passed to bool() except None. I don't see a good reason for that so allow None as well.
* tests: skip a flaky test on pypy3Christoph Reiter2018-08-111-0/+1
| | | | | This sometimes segfaults on pypy3. I can't see why, so skip for now and reenable once pypy3 haa a stable release.
* pypy: pass a warning subclass to PyErr_Warn and not an exception, pypy ↵Christoph Reiter2018-04-221-2/+2
| | | | | | does't support that. TypeError is wrong there anyway.
* int converters: unify overflow error handlingChristoph Reiter2018-04-141-2/+13
| | | | | | | | | | | | | In case functions like PyLong_AsLong() fail we bail out and just return the error set by it. In most cases this is due to overflow and results in error messages such as "too large to convert" and "too large to convert to C long". The problem here is that for the same type of error we get different error messages depending on the Python version, the architecture (long size) or the size of the value itself. To unify the error message reraise the OverflowError with our default error message in all cases.
* Move all py2/3 compat code into gi._compatChristoph Reiter2018-04-071-3/+3
|
* tests: writing to readonly attributes raises TypeError with PyPyChristoph Reiter2018-04-051-2/+8
| | | | | Accept that case in the tests and link the bug filed upstream: https://bitbucket.org/pypy/pypy/issues/2788
* overflow tests: fix error message match in case the value is larger than longChristoph Reiter2018-04-041-3/+4
| | | | | | It will fail early in PYGLIB_PyLong_AsLong() and give us a different error message. It would be nice if the error would be independent of the long size, but that's for another time.
* pygi_gint_from_py: fix wrong range in error message, add testChristoph Reiter2018-04-041-0/+5
|
* test_gi: gc.collect() some moreChristoph Reiter2018-04-011-0/+10
| | | | | And adds a simpler version of previously failing test. Not sure about why this helps.
* enum/flags: set tp_hash on Python 2 as well; add hash() testsChristoph Reiter2018-03-311-0/+12
| | | | It shouldn't make a difference.
* tests: Skip various sys.getrefcount() checks in case sys.getrefcount is missingChristoph Reiter2018-03-311-0/+8
| | | | PyPy doesn't support it.
* tests: test genum __reduce__ implementationChristoph Reiter2018-03-191-0/+7
|
* tests: add tests for functions returning invalid utf-8. See #171Christoph Reiter2018-03-191-1/+13
| | | | | I can't reproduce the error here, so I'm probably missing something. Having this tested is a good idea either way.
* test_gi: cover more GIMarshallingTests functionsChristoph Reiter2018-03-141-2/+88
| | | | some of them skipped as they crash
* IntrospectionModule: __path__ should be List[str] and not strChristoph Reiter2018-03-111-2/+4
| | | | | | | | This fixes a crash when calling help() on the module which got stricter with Python 3.7. It's a bit questionable why the type has __path__ in the first place as that's only meant for packages. But let's leave that for now.
* tests_gi: Use capture_output() context manager instead of manually mocking ↵Christoph Reiter2018-03-111-11/+3
| | | | stdout
* Revert "Revert "to python struct marshalling: copy boxed during cleanup""Mathieu Duponchelle2018-02-161-1/+0
| | | | This reverts commit 10c062001ddd948b0a70545cbf613b38ed6fa46c.
* Revert "Revert "Revert "Refactor boxed wrapper memory management strategy"""Mathieu Duponchelle2018-02-161-0/+1
| | | | This reverts commit a506d5e3c64321c43a4ce7c2a72ca8d36e985999.
* Revert "Revert "Refactor boxed wrapper memory management strategy""Christoph Reiter2018-02-131-1/+0
| | | | This reverts commit daefdfa3e4dc97b4ae38250358d722f09764cc9b.
* Revert "to python struct marshalling: copy boxed during cleanup"Christoph Reiter2018-02-131-0/+1
| | | | This reverts commit 7ed8191818733b9130bce84f782dc6f8f734abf7.
* tests: Make it possible to use pytest directlywip/creiter/pytest-directChristoph Reiter2018-02-121-2/+4
| | | | | | | | | | | 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
* tests: remove locale test for uppercasing C namesChristoph Reiter2018-02-091-31/+0
| | | | | | | | | | | Someone on IRC had problems running the test suite, and that's not the first time, so remove it for now (added in 63c7f17c2248) The locale generation adds extra dependencies and only works on Linux, and while the test does something useful it complicates things too much. We need to find a better way (in Python if possible) to test for locale dependend upper()/lower().
* test: revert parts of the previous test as it's broken on 32 bit buildsChristoph Reiter2017-10-261-1/+0
| | | | | | | The int based flag type can't represent the flag value on 32 bit, some more work is needed there. Remove that check again for now. https://bugzilla.gnome.org/show_bug.cgi?id=786948
* flags: Add testcase for bug 786948Christoph Reiter2017-10-241-0/+5
| | | | | | | | Add a flags type which has a value with the highes bit set and fits in an int. While the C type is a signed int, the type is registered as flags, which GI interprets as unsigned. https://bugzilla.gnome.org/show_bug.cgi?id=786948
* to_py_array: Properly handle enum array itemsChristoph Reiter2017-10-221-0/+6
| | | | | | | It used the fallback path and copied pointers. Do the same thing we do for integer items instead. https://bugzilla.gnome.org/show_bug.cgi?id=788890
* tests: some more C locale fixesChristoph Reiter2017-10-131-2/+4
| | | | see f40df0a09803ec9c729d842f1f83c6d56aebac22
* tests: Make the test suite pass with the C localeChristoph Reiter2017-10-131-4/+25
| | | | Some filename tests assumed a Unicode locale, skip those.
* tests: skip some failing test under Windows with Python 3.6Christoph Reiter2017-08-251-7/+17
| | | | | Python 3.6 has changed the default filesystem encoding on Windows from mbcs to utf-8. Some tests assume mbcs, so skip them for now.
* tests: remove python 2.5/3.2 compat codeChristoph Reiter2017-04-021-17/+9
| | | | 2.7/3.3 support the u/b prefixes and both have callable()
* tests: fix invalid regex escapingChristoph Reiter2017-04-021-12/+12
| | | | | Python 3.6 got stricter here and raises warnings/errors for invalid escape sequences.
* Remove gi._gi._gobject and gi._gobject modulesChristoph Reiter2017-04-011-1/+1
| | | | | | | | | | Expose everything from _gi._gobject in _gi instead. This does not move any code around, just removes the module. Also removes the gi._gobject package and replaces it with a small dummy module in gi.__init__.py https://bugzilla.gnome.org/show_bug.cgi?id=735206
* GValue: add overflow checking for py -> gint; forward marshaling exceptionsChristoph Reiter2017-04-011-1/+6
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=769789
* Add support for bytes and non-utf-8 file names.Christoph Reiter2017-03-301-4/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Py2+Unix: Convert unicode to bytes using the fsencoding. Pass bytes as is. Returns path as bytes as is. Py2+Windows: Convert unicode to wtf-8. Pass bytes as is. Returns path as bytes as is. Py3+Unix: Convert str using os.fsencode so that the surrogateescape handler can restore the real path if the source was a Python API such as os.listdir sys.argv etc. Pass bytes as is. Return str decoded using os.fsdecode so that it can be passed to Python API such as open, os.listdir etc. Py3+Windows: Convert str to wtf-8. Decode bytes using the fsencoding first. Returns str + surrogates. This change makes anyting taking filenames on Python 3 behave the same as Python functions like listdir() or open(). Compared to Python 3 builtin functions which return the same type that was passed in we always return str. One remaining problem is that glib assumes that Windows paths are utf-16, while they are just 16bit arrays and as a result utf-8 is not enough to represent all possible paths. We use wtf-8 here instead (utf-8 with lone surrogates), which allows us to convert all paths, but glib functions accessing the fs will fail with them. PyUnicode_EncodeFSDefault was added in CPython 3.2 so bump the requirement. https://bugzilla.gnome.org/show_bug.cgi?id=746564
* test_gi: use correct min/max constants for gsize/gssizeChristoph Reiter2017-03-291-3/+3
| | | | | | This made these tests on 64bit Windows fail because sizeof(gsize) != sizeof(glong) https://bugzilla.gnome.org/show_bug.cgi?id=780591
* tests: Make test suite run on WindowsChristoph Reiter2017-03-241-3/+4
| | | | | | | | | | | | (in a msys2 environment) * Replace LD_LIBRARY_PATH with gir code in runtests.py * Remove unneeded runtests-windows.py * Unset MSYSTEM to disable path separator hacks by msys2 * Set sys.path in runtests.py * Skip various tests failing/hanging/crashing on Windows https://bugzilla.gnome.org/show_bug.cgi?id=780396
* tests: Make test suite run on macOSChristoph Reiter2017-03-241-0/+4
| | | | | | | * 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
* Handle nullable filename parametersChristoph Reiter2016-09-031-0/+4
| | | | | | | | | | | Make _pygi_marshal_from_py_filename handle None input values. This allows one to pass None to parameters annotated as nullable filenames. This fixes a test suite error in test_spawn_async_with_pipes triggered by an annotation change in glib. https://bugzilla.gnome.org/show_bug.cgi?id=770821
* Fix list/hashtable enum <-> hash conversion on 64-bit big endianAurelien Jarno2016-09-031-0/+11
| | | | | | | | | | | | | | | | | | | | | | glist and ghashtable objects both store pointers. Complex objects are stored as pointers to the objects, but simpler objects like an integer value are stored directly as a pointer, using for example the GINT_TO_POINTER and GPOINTER_TO_INT macros. This is done in pygobject with the _pygi_hash_pointer_to_arg and _pygi_arg_to_hash_pointer functions. These functions handle the various type of objects. However they consider that an enum, represented with the GI_TYPE_TAG_INTERFACE type (extended interface object), are always a pointer. This is wrong as it is often a 32-bit value. Therefore on 64-bit big endian machines, the value is handle with the 2 32-bit parts swapped. This patches fixes that by changing the second argument of both functions from GITypeTag to GITypeInfo. This way the interface can be determined, and the underlying storage type can also be determined. This currently only handles enum and flags, leaving other types as pointers. The patch also adds two tests in the testsuite, one for each direction. https://bugzilla.gnome.org/show_bug.cgi?id=770608
* enum/flags: use gir info for type names and __repr__ instead of the gtype nameChristoph Reiter2015-10-271-0/+41
| | | | | | | For example __name__ is now SpawnFlags instead of PyGLibSpawnFlags and __repr__ shows GLib.SpawnFlags in stead of PyGLibSpawnFlags. https://bugzilla.gnome.org/show_bug.cgi?id=657915
* Improve and unify __repr__ format for PyGObject, PyGBoxed and PyGIStructChristoph Reiter2015-10-271-0/+33
| | | | | | | | | | | | | | Includes the module, Python type name, pointer and wrapper pointer and GType name. e.g. "<Gtk.Border object at 0x7f26bee9e4c8 (GtkBorder at 0x1c72e30)>" In case of PyGObjects created from GType set the module to __gi__ instead of guessing the old static binding name. Also remove the code that tries to add them to the guessed static bindings module while at it. The __repr__ will now return "<__gi__.X11Keymap ..." instead of "<gtk.gdk.X11Keymap ..." https://bugzilla.gnome.org/show_bug.cgi?id=657915
* tests: Silence various error messages and warnings.Christoph Reiter2015-07-021-1/+5
| | | | | | | | | | | | | | 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
* Add gi.PyGIWarning and use it instead of PyGIDeprecationWarning in case the ↵Christoph Reiter2015-06-021-0/+15
| | | | | | | | | version to import wasn't specified. This makes the warning visible by default. See commit ef3bff4e570363e4f383d4cdae9cecd4073b03d8 for more info on the warning. https://bugzilla.gnome.org/show_bug.cgi?id=727379
* tests: Don't use deprecated override attributesChristoph Reiter2015-03-031-32/+34
| | | | | | | | | | | 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