gpiod 2.1.2__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {gpiod-2.1.2 → gpiod-2.2.0}/MANIFEST.in +1 -0
  2. {gpiod-2.1.2 → gpiod-2.2.0}/PKG-INFO +11 -1
  3. {gpiod-2.1.2 → gpiod-2.2.0}/README.md +10 -0
  4. gpiod-2.2.0/build_tests.py +95 -0
  5. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/chip.py +1 -1
  6. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/line.py +3 -0
  7. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/line_settings.py +1 -1
  8. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/version.py +1 -1
  9. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod.egg-info/PKG-INFO +11 -1
  10. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod.egg-info/SOURCES.txt +2 -0
  11. {gpiod-2.1.2 → gpiod-2.2.0}/lib/chip.c +8 -9
  12. {gpiod-2.1.2 → gpiod-2.2.0}/lib/internal.c +13 -0
  13. {gpiod-2.1.2 → gpiod-2.2.0}/lib/internal.h +1 -0
  14. {gpiod-2.1.2 → gpiod-2.2.0}/lib/line-config.c +0 -3
  15. {gpiod-2.1.2 → gpiod-2.2.0}/lib/line-request.c +6 -5
  16. gpiod-2.2.0/libgpiod-version.txt +1 -0
  17. {gpiod-2.1.2 → gpiod-2.2.0}/tests/__main__.py +1 -0
  18. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_chip.py +4 -1
  19. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_edge_event.py +1 -1
  20. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_info_event.py +1 -1
  21. gpiod-2.2.0/tests/tests_line.py +11 -0
  22. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_line_settings.py +6 -3
  23. gpiod-2.1.2/libgpiod-version.txt +0 -1
  24. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/__init__.py +0 -0
  25. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/chip_info.py +0 -0
  26. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/edge_event.py +0 -0
  27. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/exception.py +0 -0
  28. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/chip.c +0 -0
  29. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/common.c +0 -0
  30. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/internal.h +0 -0
  31. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/line-config.c +0 -0
  32. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/line-settings.c +0 -0
  33. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/module.c +0 -0
  34. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/ext/request.c +0 -0
  35. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/info_event.py +0 -0
  36. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/internal.py +0 -0
  37. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/line_info.py +0 -0
  38. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod/line_request.py +0 -0
  39. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod.egg-info/dependency_links.txt +0 -0
  40. {gpiod-2.1.2 → gpiod-2.2.0}/gpiod.egg-info/top_level.txt +0 -0
  41. {gpiod-2.1.2 → gpiod-2.2.0}/include/gpiod.h +0 -0
  42. {gpiod-2.1.2 → gpiod-2.2.0}/lib/chip-info.c +0 -0
  43. {gpiod-2.1.2 → gpiod-2.2.0}/lib/edge-event.c +0 -0
  44. {gpiod-2.1.2 → gpiod-2.2.0}/lib/info-event.c +0 -0
  45. {gpiod-2.1.2 → gpiod-2.2.0}/lib/line-info.c +0 -0
  46. {gpiod-2.1.2 → gpiod-2.2.0}/lib/line-settings.c +0 -0
  47. {gpiod-2.1.2 → gpiod-2.2.0}/lib/misc.c +0 -0
  48. {gpiod-2.1.2 → gpiod-2.2.0}/lib/request-config.c +0 -0
  49. {gpiod-2.1.2 → gpiod-2.2.0}/lib/uapi/gpio.h +0 -0
  50. {gpiod-2.1.2 → gpiod-2.2.0}/pyproject.toml +0 -0
  51. {gpiod-2.1.2 → gpiod-2.2.0}/setup.cfg +0 -0
  52. {gpiod-2.1.2 → gpiod-2.2.0}/setup.py +0 -0
  53. {gpiod-2.1.2 → gpiod-2.2.0}/tests/__init__.py +0 -0
  54. {gpiod-2.1.2 → gpiod-2.2.0}/tests/gpiosim/__init__.py +0 -0
  55. {gpiod-2.1.2 → gpiod-2.2.0}/tests/gpiosim/chip.py +0 -0
  56. {gpiod-2.1.2 → gpiod-2.2.0}/tests/gpiosim/ext.c +0 -0
  57. {gpiod-2.1.2 → gpiod-2.2.0}/tests/helpers.py +0 -0
  58. {gpiod-2.1.2 → gpiod-2.2.0}/tests/procname/__init__.py +0 -0
  59. {gpiod-2.1.2 → gpiod-2.2.0}/tests/procname/ext.c +0 -0
  60. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_chip_info.py +0 -0
  61. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_line_info.py +0 -0
  62. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_line_request.py +0 -0
  63. {gpiod-2.1.2 → gpiod-2.2.0}/tests/tests_module.py +0 -0
@@ -2,6 +2,7 @@
2
2
  # SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
3
3
 
4
4
  include setup.py
5
+ include build_tests.py
5
6
  include README.md
6
7
  include libgpiod-version.txt
7
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gpiod
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Python bindings for libgpiod
5
5
  Home-page: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
6
6
  Author: Bartosz Golaszewski
@@ -114,3 +114,13 @@ with gpiod.request_lines(
114
114
  time.sleep(1)
115
115
  ```
116
116
 
117
+ ## Testing
118
+
119
+ The test suite for the python bindings can be run by calling:
120
+
121
+ ```
122
+ make python-tests-run
123
+ ```
124
+
125
+ from the `libgpiod/bindings/python` directory as root (necessary to be able
126
+ to create the **gpio-sims** used for testing).
@@ -102,3 +102,13 @@ with gpiod.request_lines(
102
102
  time.sleep(1)
103
103
  ```
104
104
 
105
+ ## Testing
106
+
107
+ The test suite for the python bindings can be run by calling:
108
+
109
+ ```
110
+ make python-tests-run
111
+ ```
112
+
113
+ from the `libgpiod/bindings/python` directory as root (necessary to be able
114
+ to create the **gpio-sims** used for testing).
@@ -0,0 +1,95 @@
1
+ # SPDX-License-Identifier: GPL-2.0-or-later
2
+ # SPDX-FileCopyrightText: 2023 Phil Howard <phil@gadgetoid.com>
3
+
4
+ """
5
+ Bring up just enough of setuptools/distutils in order to build the gpiod
6
+ test module C extensions.
7
+
8
+ Set "build_temp" and "build_lib" so that our source directory is not
9
+ polluted with artefacts in build/
10
+
11
+ Builds:
12
+
13
+ tests/gpiosim/_ext.<target>.so
14
+ tests/procname/_ext.<target>.so
15
+
16
+ """
17
+
18
+ import glob
19
+ import tempfile
20
+ from os import getenv, path
21
+
22
+ from setuptools import Distribution, Extension
23
+ from setuptools.command.build_ext import build_ext
24
+
25
+ TOP_SRCDIR = getenv("TOP_SRCDIR", "../../")
26
+ TOP_BUILDDIR = getenv("TOP_BUILDDIR", "../../")
27
+
28
+ # __version__
29
+ with open("gpiod/version.py", "r") as fd:
30
+ exec(fd.read())
31
+
32
+ # The tests are run in-place with PYTHONPATH set to bindings/python
33
+ # so we need the gpiod extension module too.
34
+ gpiod_ext = Extension(
35
+ "gpiod._ext",
36
+ sources=glob.glob("gpiod/ext/*.c"),
37
+ define_macros=[("_GNU_SOURCE", "1")],
38
+ libraries=["gpiod"],
39
+ extra_compile_args=["-Wall", "-Wextra"],
40
+ include_dirs=[
41
+ path.join(TOP_SRCDIR, "include"),
42
+ ],
43
+ library_dirs=[
44
+ path.join(TOP_BUILDDIR, "lib/.libs"),
45
+ ],
46
+ )
47
+
48
+ gpiosim_ext = Extension(
49
+ "tests.gpiosim._ext",
50
+ sources=["tests/gpiosim/ext.c"],
51
+ define_macros=[("_GNU_SOURCE", "1")],
52
+ libraries=["gpiosim"],
53
+ extra_compile_args=["-Wall", "-Wextra"],
54
+ include_dirs=[
55
+ path.join(TOP_SRCDIR, "include"),
56
+ path.join(TOP_SRCDIR, "tests/gpiosim"),
57
+ ],
58
+ library_dirs=[
59
+ path.join(TOP_BUILDDIR, "lib/.libs"),
60
+ path.join(TOP_BUILDDIR, "tests/gpiosim/.libs"),
61
+ ],
62
+ )
63
+
64
+ procname_ext = Extension(
65
+ "tests.procname._ext",
66
+ sources=["tests/procname/ext.c"],
67
+ define_macros=[("_GNU_SOURCE", "1")],
68
+ extra_compile_args=["-Wall", "-Wextra"],
69
+ )
70
+
71
+ dist = Distribution(
72
+ {
73
+ "name": "gpiod",
74
+ "ext_modules": [gpiosim_ext, procname_ext, gpiod_ext],
75
+ "version": __version__,
76
+ "platforms": ["linux"],
77
+ }
78
+ )
79
+
80
+ try:
81
+ from setuptools.logging import configure
82
+
83
+ configure()
84
+ except ImportError:
85
+ from distutils.log import DEBUG, set_verbosity
86
+
87
+ set_verbosity(DEBUG)
88
+
89
+ with tempfile.TemporaryDirectory(prefix="libgpiod-") as temp_dir:
90
+ command = build_ext(dist)
91
+ command.inplace = True
92
+ command.build_temp = temp_dir
93
+ command.build_lib = temp_dir
94
+ command.finalize_options()
95
+ command.run()
@@ -333,7 +333,7 @@ class Chip:
333
333
  if not self._chip:
334
334
  return "<Chip CLOSED>"
335
335
 
336
- return 'Chip("{}")'.format(self.path)
336
+ return 'gpiod.Chip("{}")'.format(self.path)
337
337
 
338
338
  def __str__(self) -> str:
339
339
  """
@@ -14,6 +14,9 @@ class Value(Enum):
14
14
  INACTIVE = _ext.VALUE_INACTIVE
15
15
  ACTIVE = _ext.VALUE_ACTIVE
16
16
 
17
+ def __bool__(self):
18
+ return self == self.ACTIVE
19
+
17
20
 
18
21
  class Direction(Enum):
19
22
  """Direction settings."""
@@ -27,7 +27,7 @@ class LineSettings:
27
27
  # __repr__ generated by @dataclass uses repr for enum members resulting in
28
28
  # an unusable representation as those are of the form: <NAME: $value>
29
29
  def __repr__(self):
30
- return "LineSettings(direction={}, edge_detection={} bias={} drive={} active_low={} debounce_period={} event_clock={} output_value={})".format(
30
+ return "gpiod.LineSettings(direction={}, edge_detection={}, bias={}, drive={}, active_low={}, debounce_period={}, event_clock={}, output_value={})".format(
31
31
  str(self.direction),
32
32
  str(self.edge_detection),
33
33
  str(self.bias),
@@ -2,4 +2,4 @@
2
2
  # SPDX-FileCopyrightText: 2022 Linaro Ltd.
3
3
  # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
4
4
 
5
- __version__ = "2.1.2"
5
+ __version__ = "2.2.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gpiod
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Python bindings for libgpiod
5
5
  Home-page: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
6
6
  Author: Bartosz Golaszewski
@@ -114,3 +114,13 @@ with gpiod.request_lines(
114
114
  time.sleep(1)
115
115
  ```
116
116
 
117
+ ## Testing
118
+
119
+ The test suite for the python bindings can be run by calling:
120
+
121
+ ```
122
+ make python-tests-run
123
+ ```
124
+
125
+ from the `libgpiod/bindings/python` directory as root (necessary to be able
126
+ to create the **gpio-sims** used for testing).
@@ -1,5 +1,6 @@
1
1
  MANIFEST.in
2
2
  README.md
3
+ build_tests.py
3
4
  libgpiod-version.txt
4
5
  pyproject.toml
5
6
  setup.py
@@ -47,6 +48,7 @@ tests/tests_chip.py
47
48
  tests/tests_chip_info.py
48
49
  tests/tests_edge_event.py
49
50
  tests/tests_info_event.py
51
+ tests/tests_line.py
50
52
  tests/tests_line_info.py
51
53
  tests/tests_line_request.py
52
54
  tests/tests_line_settings.py
@@ -7,7 +7,6 @@
7
7
  #include <gpiod.h>
8
8
  #include <stdlib.h>
9
9
  #include <string.h>
10
- #include <sys/ioctl.h>
11
10
  #include <unistd.h>
12
11
 
13
12
  #include "internal.h"
@@ -72,7 +71,7 @@ static int read_chip_info(int fd, struct gpiochip_info *info)
72
71
 
73
72
  memset(info, 0, sizeof(*info));
74
73
 
75
- ret = ioctl(fd, GPIO_GET_CHIPINFO_IOCTL, info);
74
+ ret = gpiod_ioctl(fd, GPIO_GET_CHIPINFO_IOCTL, info);
76
75
  if (ret)
77
76
  return -1;
78
77
 
@@ -87,7 +86,7 @@ GPIOD_API struct gpiod_chip_info *gpiod_chip_get_info(struct gpiod_chip *chip)
87
86
  assert(chip);
88
87
 
89
88
  ret = read_chip_info(chip->fd, &info);
90
- if (ret < 0)
89
+ if (ret)
91
90
  return NULL;
92
91
 
93
92
  return gpiod_chip_info_from_uapi(&info);
@@ -111,7 +110,7 @@ static int chip_read_line_info(int fd, unsigned int offset,
111
110
  cmd = watch ? GPIO_V2_GET_LINEINFO_WATCH_IOCTL :
112
111
  GPIO_V2_GET_LINEINFO_IOCTL;
113
112
 
114
- ret = ioctl(fd, cmd, info);
113
+ ret = gpiod_ioctl(fd, cmd, info);
115
114
  if (ret)
116
115
  return -1;
117
116
 
@@ -150,7 +149,7 @@ GPIOD_API int gpiod_chip_unwatch_line_info(struct gpiod_chip *chip,
150
149
  {
151
150
  assert(chip);
152
151
 
153
- return ioctl(chip->fd, GPIO_GET_LINEINFO_UNWATCH_IOCTL, &offset);
152
+ return gpiod_ioctl(chip->fd, GPIO_GET_LINEINFO_UNWATCH_IOCTL, &offset);
154
153
  }
155
154
 
156
155
  GPIOD_API int gpiod_chip_get_fd(struct gpiod_chip *chip)
@@ -192,7 +191,7 @@ GPIOD_API int gpiod_chip_get_line_offset_from_name(struct gpiod_chip *chip,
192
191
  }
193
192
 
194
193
  ret = read_chip_info(chip->fd, &chinfo);
195
- if (ret < 0)
194
+ if (ret)
196
195
  return -1;
197
196
 
198
197
  for (offset = 0; offset < chinfo.lines; offset++) {
@@ -235,11 +234,11 @@ gpiod_chip_request_lines(struct gpiod_chip *chip,
235
234
  return NULL;
236
235
 
237
236
  ret = read_chip_info(chip->fd, &info);
238
- if (ret < 0)
237
+ if (ret)
239
238
  return NULL;
240
239
 
241
- ret = ioctl(chip->fd, GPIO_V2_GET_LINE_IOCTL, &uapi_req);
242
- if (ret < 0)
240
+ ret = gpiod_ioctl(chip->fd, GPIO_V2_GET_LINE_IOCTL, &uapi_req);
241
+ if (ret)
243
242
  return NULL;
244
243
 
245
244
  request = gpiod_line_request_from_uapi(&uapi_req, info.name);
@@ -7,6 +7,7 @@
7
7
  #include <stdio.h>
8
8
  #include <stdlib.h>
9
9
  #include <string.h>
10
+ #include <sys/ioctl.h>
10
11
  #include <sys/stat.h>
11
12
  #include <sys/sysmacros.h>
12
13
  #include <sys/types.h>
@@ -121,6 +122,18 @@ int gpiod_set_output_value(enum gpiod_line_value in, enum gpiod_line_value *out)
121
122
  return 0;
122
123
  }
123
124
 
125
+ int gpiod_ioctl(int fd, unsigned long request, void *arg)
126
+ {
127
+ int ret;
128
+
129
+ ret = ioctl(fd, request, arg);
130
+ if (ret <= 0)
131
+ return ret;
132
+
133
+ errno = EBADE;
134
+ return -1;
135
+ }
136
+
124
137
  void gpiod_line_mask_zero(uint64_t *mask)
125
138
  {
126
139
  *mask = 0ULL;
@@ -38,6 +38,7 @@ struct gpiod_info_event *gpiod_info_event_read_fd(int fd);
38
38
  int gpiod_poll_fd(int fd, int64_t timeout);
39
39
  int gpiod_set_output_value(enum gpiod_line_value in,
40
40
  enum gpiod_line_value *out);
41
+ int gpiod_ioctl(int fd, unsigned long request, void *arg);
41
42
 
42
43
  void gpiod_line_mask_zero(uint64_t *mask);
43
44
  bool gpiod_line_mask_test_bit(const uint64_t *mask, int nr);
@@ -381,18 +381,15 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
381
381
  case GPIOD_LINE_EDGE_FALLING:
382
382
  flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
383
383
  GPIO_V2_LINE_FLAG_INPUT);
384
- flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
385
384
  break;
386
385
  case GPIOD_LINE_EDGE_RISING:
387
386
  flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
388
387
  GPIO_V2_LINE_FLAG_INPUT);
389
- flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
390
388
  break;
391
389
  case GPIOD_LINE_EDGE_BOTH:
392
390
  flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
393
391
  GPIO_V2_LINE_FLAG_EDGE_RISING |
394
392
  GPIO_V2_LINE_FLAG_INPUT);
395
- flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
396
393
  break;
397
394
  default:
398
395
  break;
@@ -6,7 +6,6 @@
6
6
  #include <gpiod.h>
7
7
  #include <stdlib.h>
8
8
  #include <string.h>
9
- #include <sys/ioctl.h>
10
9
  #include <sys/param.h>
11
10
  #include <unistd.h>
12
11
 
@@ -153,7 +152,8 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
153
152
 
154
153
  uapi_values.mask = mask;
155
154
 
156
- ret = ioctl(request->fd, GPIO_V2_LINE_GET_VALUES_IOCTL, &uapi_values);
155
+ ret = gpiod_ioctl(request->fd, GPIO_V2_LINE_GET_VALUES_IOCTL,
156
+ &uapi_values);
157
157
  if (ret)
158
158
  return -1;
159
159
 
@@ -218,7 +218,8 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
218
218
  uapi_values.mask = mask;
219
219
  uapi_values.bits = bits;
220
220
 
221
- return ioctl(request->fd, GPIO_V2_LINE_SET_VALUES_IOCTL, &uapi_values);
221
+ return gpiod_ioctl(request->fd, GPIO_V2_LINE_SET_VALUES_IOCTL,
222
+ &uapi_values);
222
223
  }
223
224
 
224
225
  GPIOD_API int gpiod_line_request_set_values(struct gpiod_line_request *request,
@@ -271,8 +272,8 @@ gpiod_line_request_reconfigure_lines(struct gpiod_line_request *request,
271
272
  return -1;
272
273
  }
273
274
 
274
- ret = ioctl(request->fd, GPIO_V2_LINE_SET_CONFIG_IOCTL,
275
- &uapi_cfg.config);
275
+ ret = gpiod_ioctl(request->fd, GPIO_V2_LINE_SET_CONFIG_IOCTL,
276
+ &uapi_cfg.config);
276
277
  if (ret)
277
278
  return ret;
278
279
 
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -8,6 +8,7 @@ from .tests_chip import *
8
8
  from .tests_chip_info import *
9
9
  from .tests_edge_event import *
10
10
  from .tests_info_event import *
11
+ from .tests_line import *
11
12
  from .tests_line_info import *
12
13
  from .tests_line_settings import *
13
14
  from .tests_module import *
@@ -202,7 +202,10 @@ class StringRepresentation(TestCase):
202
202
  self.sim = None
203
203
 
204
204
  def test_repr(self):
205
- self.assertEqual(repr(self.chip), 'Chip("{}")'.format(self.sim.dev_path))
205
+ self.assertEqual(repr(self.chip), 'gpiod.Chip("{}")'.format(self.sim.dev_path))
206
+
207
+ cmp = eval(repr(self.chip))
208
+ self.assertEqual(self.chip.path, cmp.path)
206
209
 
207
210
  def test_str(self):
208
211
  info = self.chip.get_info()
@@ -208,5 +208,5 @@ class EdgeEventStringRepresentation(TestCase):
208
208
  event = req.read_edge_events()[0]
209
209
  self.assertRegex(
210
210
  str(event),
211
- "<EdgeEvent type=Type\.RISING_EDGE timestamp_ns=[0-9]+ line_offset=0 global_seqno=1 line_seqno=1>",
211
+ "<EdgeEvent type=Type\\.RISING_EDGE timestamp_ns=[0-9]+ line_offset=0 global_seqno=1 line_seqno=1>",
212
212
  )
@@ -185,5 +185,5 @@ class InfoEventStringRepresentation(TestCase):
185
185
  event = chip.read_info_event()
186
186
  self.assertRegex(
187
187
  str(event),
188
- '<InfoEvent type=Type\.LINE_REQUESTED timestamp_ns=[0-9]+ line_info=<LineInfo offset=0 name="None" used=True consumer="\?" direction=Direction\.INPUT active_low=False bias=Bias\.UNKNOWN drive=Drive\.PUSH_PULL edge_detection=Edge\.NONE event_clock=Clock\.MONOTONIC debounced=False debounce_period=0:00:00>>',
188
+ '<InfoEvent type=Type\\.LINE_REQUESTED timestamp_ns=[0-9]+ line_info=<LineInfo offset=0 name="None" used=True consumer="\\?" direction=Direction\\.INPUT active_low=False bias=Bias\\.UNKNOWN drive=Drive\\.PUSH_PULL edge_detection=Edge\\.NONE event_clock=Clock\\.MONOTONIC debounced=False debounce_period=0:00:00>>',
189
189
  )
@@ -0,0 +1,11 @@
1
+ # SPDX-License-Identifier: LGPL-2.1-or-later
2
+ # SPDX-FileCopyrightText: 2024 Kent Gibson <warthog618@gmail.com>
3
+
4
+ from gpiod.line import Value
5
+ from unittest import TestCase
6
+
7
+
8
+ class LineValue(TestCase):
9
+ def test_cast_bool(self):
10
+ self.assertTrue(bool(Value.ACTIVE))
11
+ self.assertFalse(bool(Value.INACTIVE))
@@ -1,10 +1,10 @@
1
1
  # SPDX-License-Identifier: LGPL-2.1-or-later
2
2
  # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
3
3
 
4
+ import datetime
4
5
  import gpiod
5
6
 
6
7
  from . import gpiosim
7
- from datetime import timedelta
8
8
  from gpiod.line import Direction, Edge, Bias, Drive, Value, Clock
9
9
  from unittest import TestCase
10
10
 
@@ -47,7 +47,7 @@ class LineSettingsAttributes(TestCase):
47
47
  settings.direction = Direction.INPUT
48
48
  settings.edge_detection = Edge.BOTH
49
49
  settings.bias = Bias.DISABLED
50
- settings.debounce_period = timedelta(microseconds=3000)
50
+ settings.debounce_period = datetime.timedelta(microseconds=3000)
51
51
  settings.event_clock = Clock.HTE
52
52
 
53
53
  self.assertEqual(settings.direction, Direction.INPUT)
@@ -69,9 +69,12 @@ class LineSettingsStringRepresentation(TestCase):
69
69
  def test_repr(self):
70
70
  self.assertEqual(
71
71
  repr(self.settings),
72
- "LineSettings(direction=Direction.OUTPUT, edge_detection=Edge.NONE bias=Bias.AS_IS drive=Drive.OPEN_SOURCE active_low=True debounce_period=datetime.timedelta(0) event_clock=Clock.MONOTONIC output_value=Value.INACTIVE)",
72
+ "gpiod.LineSettings(direction=Direction.OUTPUT, edge_detection=Edge.NONE, bias=Bias.AS_IS, drive=Drive.OPEN_SOURCE, active_low=True, debounce_period=datetime.timedelta(0), event_clock=Clock.MONOTONIC, output_value=Value.INACTIVE)",
73
73
  )
74
74
 
75
+ cmp = eval(repr(self.settings))
76
+ self.assertEqual(self.settings, cmp)
77
+
75
78
  def test_str(self):
76
79
  self.assertEqual(
77
80
  str(self.settings),
@@ -1 +0,0 @@
1
- 2.1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes