bindings: python: examples: new test case
authorBartosz Golaszewski <bartekgola@gmail.com>
Sun, 22 Jul 2018 18:12:40 +0000 (20:12 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Sun, 22 Jul 2018 18:14:50 +0000 (20:14 +0200)
Add a test case for incorrect number of default values in line
requests.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
bindings/python/examples/gpiod_tests.py

index 4c2f9a8a273ad71785012ac800584ff0288bf1c7..6a30a4c9415a2f23bd4f3f8c365e099335c54167 100755 (executable)
@@ -309,6 +309,23 @@ def request_multiple_lines_with_default_values():
 
 add_test('Request multiple lines with default values', request_multiple_lines_with_default_values)
 
+def request_line_incorrect_number_of_def_vals():
+    with gpiod.Chip('gpiochip0') as chip:
+        lines = chip.get_lines(( 1, 2, 3, 4, 5 ))
+
+        print('requesting lines with incorrect number of default values')
+        try:
+            lines.request(consumer='gpiod_test.py',
+                          type=gpiod.LINE_REQ_DIR_OUT,
+                          default_vals=( 1, 0, 1, 0 ))
+        except TypeError:
+            print('TypeError raised as expected')
+            return
+
+        assert False, 'TypeError expected'
+
+add_test('Request with incorrect number of default values', request_line_incorrect_number_of_def_vals)
+
 def line_event_single_line():
     chip = gpiod.Chip('gpiochip0')
     line = chip.get_line(1)