bindings: python: tests: add test for casting line.Value to bool
authorKent Gibson <warthog618@gmail.com>
Wed, 22 May 2024 00:46:42 +0000 (08:46 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 23 May 2024 07:51:53 +0000 (09:51 +0200)
The line.Value represents the logical line state, so intuitively you
would expect it to be able to be cast to bool, with ACTIVE
corresponding to True, and INACTIVE to False.

Add a test that line.Value can be cast to bool.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20240522004643.96863-2-warthog618@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
bindings/python/tests/Makefile.am
bindings/python/tests/tests_line.py [new file with mode: 0644]

index c89241ed8bd5f74a4e64811c70829f849a03f21a..3118d5f23fd9eef9ad474512e3d729a1272ff468 100644 (file)
@@ -11,6 +11,7 @@ EXTRA_DIST = \
        tests_chip.py \
        tests_edge_event.py \
        tests_info_event.py \
+       tests_line.py \
        tests_line_info.py \
        tests_line_request.py \
        tests_line_settings.py \
diff --git a/bindings/python/tests/tests_line.py b/bindings/python/tests/tests_line.py
new file mode 100644 (file)
index 0000000..70aa09b
--- /dev/null
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# SPDX-FileCopyrightText: 2024 Kent Gibson <warthog618@gmail.com>
+
+from gpiod.line import Value
+from unittest import TestCase
+
+
+class LineValue(TestCase):
+    def test_cast_bool(self):
+        self.assertTrue(bool(Value.ACTIVE))
+        self.assertFalse(bool(Value.INACTIVE))