python: factor out user_attributes getters and setters
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 16 Oct 2023 20:25:32 +0000 (16:25 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2024 16:17:44 +0000 (11:17 -0500)
commit568865d9b2138625f9c4f99adcc94dea6affac69
tree6d09f2da7d95c9077a5b2ab7f53d5b4f6a3a5ff3
parent045ba586ed4933c2f0c52cfa9908df3639af7ffc
python: factor out user_attributes getters and setters

To avoid repeating the `user_attributes()` methods everywhere, define
two mixin classes (_WithUserAttributesConst and _WithUserAttributes) and
use them throughout.

Note that this fixes a bug where _StreamClassConst.user_attributes would
return a (non-const) MapValue, since it used
bt2_value._create_from_ptr_and_get_ref, instead of
bt2_value._create_from_const_ptr_and_get_ref.

Improve tests to fill in some gaps we had in the testing of user
attributes.  For all objects types that have user attributes, test
getting the user attributes from both the non-const and const versions
of the object, and verify that the return value of the
`user_attributes()` method is of the correct type.

Change-Id: I4a7542f015b5f3245395d64175761fe34aa1753f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10243
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
15 files changed:
src/bindings/python/bt2/Makefile.am
src/bindings/python/bt2/bt2/clock_class.py
src/bindings/python/bt2/bt2/event_class.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/stream.py
src/bindings/python/bt2/bt2/stream_class.py
src/bindings/python/bt2/bt2/trace.py
src/bindings/python/bt2/bt2/trace_class.py
src/bindings/python/bt2/bt2/user_attributes.py [new file with mode: 0644]
tests/bindings/python/bt2/test_clock_class.py
tests/bindings/python/bt2/test_stream.py
tests/bindings/python/bt2/test_stream_class.py
tests/bindings/python/bt2/test_trace.py
tests/bindings/python/bt2/test_trace_class.py
tests/bindings/python/bt2/utils.py
This page took 0.025404 seconds and 4 git commands to generate.