From: Bartosz Golaszewski Date: Sun, 22 Jul 2018 18:12:40 +0000 (+0200) Subject: bindings: python: examples: new test case X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=445793aabf7cf60ff9683b39aacfc4ea4739aed1;p=qemu-gpiodev%2Flibgpiod.git bindings: python: examples: new test case Add a test case for incorrect number of default values in line requests. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/examples/gpiod_tests.py b/bindings/python/examples/gpiod_tests.py index 4c2f9a8..6a30a4c 100755 --- a/bindings/python/examples/gpiod_tests.py +++ b/bindings/python/examples/gpiod_tests.py @@ -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)