bindings: python: fix __repr__() implementations
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 30 Jan 2024 15:04:48 +0000 (16:04 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 5 Feb 2024 08:49:10 +0000 (09:49 +0100)
commit6d5d8afc9c7e9a7b47d54fe51f4cb8d7077cdb8b
tree7e8d5d217fd7a1c8326e6e9a74a726377c6c30bc
parentcfac97acb4392b3be317f1a18bdb12f2b7f0e2ca
bindings: python: fix __repr__() implementations

The __repr__() function should - if possible - return a valid Python
expression that can be used to instantiate a new object when evaluated.

LineSettings.__repr__() is missing comas between arguments. Both Chip and
LineSettings also don't prefix the returned string with 'gpiod.'. Fix
both functions and add more test cases - including actually using the
strings returned by __repr__() to create new objects and compare their
contents.

Reported-by: Robert Thomas <rob.thomas@raspberrypi.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
bindings/python/gpiod/chip.py
bindings/python/gpiod/line_settings.py
bindings/python/tests/tests_chip.py
bindings/python/tests/tests_line_settings.py