bindings: python: tests: add a test-case exposing a bug in Line.request()
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 9 Oct 2020 12:22:09 +0000 (14:22 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 9 Oct 2020 12:24:10 +0000 (14:24 +0200)
Calling Line.request() with no keyword arguments leads to an exception
being raised by PyDict_Size(). Add a test-case exposing this bug. It
will be fixed in the subsequent commit.

Reported-by: Jiri Benc <jbenc@upir.cz>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
bindings/python/tests/gpiod_py_test.py

index 572aad8b4d94a0354c4ff67b7a5ee8d95dc69e58..52a82c5a6d055520b2175a7f2c92635951b991e2 100755 (executable)
@@ -719,6 +719,15 @@ class LineRequestBehavior(MockupTestCase):
 
             self.assertEqual(err_ctx.exception.errno, errno.EPERM)
 
+    def test_request_with_no_kwds(self):
+        with gpiod.Chip(mockup.chip_name(0)) as chip:
+            line = chip.get_line(2)
+            line.request(default_consumer)
+            self.assertTrue(line.is_requested())
+            self.assertEqual(line.direction(), gpiod.Line.DIRECTION_INPUT)
+            line.release()
+            self.assertFalse(line.is_requested())
+
 #
 # Iterator test cases
 #