Commit e33ecf1
committed
tests: Adapt to pygobject 3.55.0
After upgrading pygobject from 3.54.5 to 3.55.2, Python tests
expecting a process failure on setting an immutable
(G_PARAM_CONSTRUCT_ONLY) property started to fail like this:
Traceback (most recent call last):
File "/home/test/libmodulemd-devel/redhat-linux-build/../modulemd/tests/ModulemdTests/defaults.py", line 114, in test_module_name
self.assertProcessFailure(_set_module_name_to_none, defs)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/test/libmodulemd-devel/modulemd/tests/ModulemdTests/base.py", line 60, in assertProcessFailure
callable(*args)
~~~~~~~~^^^^^^^
File "/home/test/libmodulemd-devel/redhat-linux-build/../modulemd/tests/ModulemdTests/defaults.py", line 43, in _set_module_name_to_none
defs.props.module_name = None
^^^^^^^^^^^^^^^^^^^^^^
TypeError: property 'module-name' can only be set in constructor
The cause was that pygobject-3.55.0 started to raise a Python
TypeError exception instead of calling Glib functions which would fail
on its own depending on Glib warning fatality and Glib version. An example:
cat /tmp/test.py
#!/usr/bin/python3
import gi
gi.require_version("Modulemd", "2.0")
from gi.repository import Modulemd
object = Modulemd.Defaults.new(Modulemd.DefaultsVersionEnum.LATEST, "foo")
object.props.module_name = "bar"
Before:
$ /tmp/test.py
/tmp/test.py:8: Warning: g_object_set_is_valid_property: construct property "module-name" for object 'ModulemdDefaultsV1' can't be set after construction
object.props.module_name = "bar"
After:
$ /tmp/test.py
Traceback (most recent call last):
File "/tmp/test.py", line 8, in <module>
object.props.module_name = "bar"
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: property 'module-name' can only be set in constructor
That was an intentional change in pygobject
3b6e4804de4f26cfb9472666f18f44ac731d874c commit (gi: Factor out
pygi_set_property_gvalue_from_property_info). Probably an
optimization.
This patch adjusts the tests to pass if TypeError exception is raised
regardless of Glib warning fatality.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=24405701 parent f3039d8 commit e33ecf1
5 files changed
Lines changed: 38 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
70 | 100 | | |
71 | 101 | | |
72 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
0 commit comments