[libgpiod][PATCH v2 17/23] bindings: python: tests: make EventType private to prevent export

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

 



Previously, both tests_edge_event and tests_info_event had a public
module level EventType member.

The __main__ module for unittests does a star import from both modules
which led to an import conflict between the two.

It is not necessary to import EventType to run unit tests.

Now, EventType is private to avoid being imported via star syntax.

Signed-off-by: Vincent Fazio <vfazio@xxxxxxxxxxx>
---
 bindings/python/tests/tests_edge_event.py | 14 +++++++-------
 bindings/python/tests/tests_info_event.py | 10 +++++-----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bindings/python/tests/tests_edge_event.py b/bindings/python/tests/tests_edge_event.py
index 7e7fada..c24d344 100644
--- a/bindings/python/tests/tests_edge_event.py
+++ b/bindings/python/tests/tests_edge_event.py
@@ -12,7 +12,7 @@ from gpiod.line import Direction, Edge
 
 from . import gpiosim
 
-EventType = gpiod.EdgeEvent.Type
+_EventType = gpiod.EdgeEvent.Type
 Pull = gpiosim.Chip.Pull
 
 
@@ -87,7 +87,7 @@ class WaitingForEdgeEvents(TestCase):
             events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
-            self.assertEqual(event.event_type, EventType.RISING_EDGE)
+            self.assertEqual(event.event_type, _EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 2)
             ts_rising = event.timestamp_ns
 
@@ -95,7 +95,7 @@ class WaitingForEdgeEvents(TestCase):
             events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
-            self.assertEqual(event.event_type, EventType.FALLING_EDGE)
+            self.assertEqual(event.event_type, _EventType.FALLING_EDGE)
             self.assertEqual(event.line_offset, 2)
             ts_falling = event.timestamp_ns
 
@@ -114,7 +114,7 @@ class WaitingForEdgeEvents(TestCase):
             events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
-            self.assertEqual(event.event_type, EventType.RISING_EDGE)
+            self.assertEqual(event.event_type, _EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 6)
 
             self.assertFalse(req.wait_edge_events(timedelta(microseconds=10000)))
@@ -132,7 +132,7 @@ class WaitingForEdgeEvents(TestCase):
             events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
-            self.assertEqual(event.event_type, EventType.FALLING_EDGE)
+            self.assertEqual(event.event_type, _EventType.FALLING_EDGE)
             self.assertEqual(event.line_offset, 6)
 
             self.assertFalse(req.wait_edge_events(timedelta(microseconds=10000)))
@@ -150,7 +150,7 @@ class WaitingForEdgeEvents(TestCase):
             events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
-            self.assertEqual(event.event_type, EventType.RISING_EDGE)
+            self.assertEqual(event.event_type, _EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 2)
             self.assertEqual(event.global_seqno, 1)
             self.assertEqual(event.line_seqno, 1)
@@ -159,7 +159,7 @@ class WaitingForEdgeEvents(TestCase):
             events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
-            self.assertEqual(event.event_type, EventType.RISING_EDGE)
+            self.assertEqual(event.event_type, _EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 4)
             self.assertEqual(event.global_seqno, 2)
             self.assertEqual(event.line_seqno, 1)
diff --git a/bindings/python/tests/tests_info_event.py b/bindings/python/tests/tests_info_event.py
index bbdbc0f..1976f4b 100644
--- a/bindings/python/tests/tests_info_event.py
+++ b/bindings/python/tests/tests_info_event.py
@@ -14,7 +14,7 @@ from gpiod.line import Direction
 
 from . import gpiosim
 
-EventType = gpiod.InfoEvent.Type
+_EventType = gpiod.InfoEvent.Type
 
 
 class InfoEventDataclassBehavior(TestCase):
@@ -101,7 +101,7 @@ class WatchingInfoEventWorks(TestCase):
 
         self.assertTrue(self.chip.wait_info_event(datetime.timedelta(seconds=1)))
         event = self.chip.read_info_event()
-        self.assertEqual(event.event_type, EventType.LINE_REQUESTED)
+        self.assertEqual(event.event_type, _EventType.LINE_REQUESTED)
         self.assertEqual(event.line_info.offset, 7)
         self.assertEqual(event.line_info.direction, Direction.INPUT)
         ts_req = event.timestamp_ns
@@ -109,14 +109,14 @@ class WatchingInfoEventWorks(TestCase):
         # Check that we can use a float directly instead of datetime.timedelta.
         self.assertTrue(self.chip.wait_info_event(1.0))
         event = self.chip.read_info_event()
-        self.assertEqual(event.event_type, EventType.LINE_CONFIG_CHANGED)
+        self.assertEqual(event.event_type, _EventType.LINE_CONFIG_CHANGED)
         self.assertEqual(event.line_info.offset, 7)
         self.assertEqual(event.line_info.direction, Direction.OUTPUT)
         ts_rec = event.timestamp_ns
 
         self.assertTrue(self.chip.wait_info_event(datetime.timedelta(seconds=1)))
         event = self.chip.read_info_event()
-        self.assertEqual(event.event_type, EventType.LINE_RELEASED)
+        self.assertEqual(event.event_type, _EventType.LINE_RELEASED)
         self.assertEqual(event.line_info.offset, 7)
         self.assertEqual(event.line_info.direction, Direction.OUTPUT)
         ts_rel = event.timestamp_ns
@@ -146,7 +146,7 @@ class UnwatchingLineInfo(TestCase):
         with self.chip.request_lines(config={0: None}) as request:
             self.assertTrue(self.chip.wait_info_event(datetime.timedelta(seconds=1)))
             event = self.chip.read_info_event()
-            self.assertEqual(event.event_type, EventType.LINE_REQUESTED)
+            self.assertEqual(event.event_type, _EventType.LINE_REQUESTED)
             self.chip.unwatch_line_info(0)
 
         self.assertFalse(
-- 
2.34.1





[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