[libgpiod][PATCH 1/2] bindings: python: tests: add test for casting line.Value to bool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 bindings/python/tests/Makefile.am   |  1 +
 bindings/python/tests/tests_line.py | 11 +++++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 bindings/python/tests/tests_line.py

diff --git a/bindings/python/tests/Makefile.am b/bindings/python/tests/Makefile.am
index c89241e..3118d5f 100644
--- a/bindings/python/tests/Makefile.am
+++ b/bindings/python/tests/Makefile.am
@@ -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
index 0000000..70aa09b
--- /dev/null
+++ b/bindings/python/tests/tests_line.py
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# SPDX-FileCopyrightText: 2024 Kent Gibson <warthog618@xxxxxxxxx>
+
+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))
-- 
2.39.2





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux