# __repr__ generated by @dataclass uses repr for enum members resulting in
# an unusable representation as those are of the form: <NAME: $value>
def __repr__(self):
- return "LineSettings(direction={}, edge_detection={} bias={} drive={} active_low={} debounce_period={} event_clock={} output_value={})".format(
+ return "gpiod.LineSettings(direction={}, edge_detection={}, bias={}, drive={}, active_low={}, debounce_period={}, event_clock={}, output_value={})".format(
str(self.direction),
str(self.edge_detection),
str(self.bias),
self.sim = None
def test_repr(self):
- self.assertEqual(repr(self.chip), 'Chip("{}")'.format(self.sim.dev_path))
+ self.assertEqual(repr(self.chip), 'gpiod.Chip("{}")'.format(self.sim.dev_path))
+
+ cmp = eval(repr(self.chip))
+ self.assertEqual(self.chip.path, cmp.path)
def test_str(self):
info = self.chip.get_info()
# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
+import datetime
import gpiod
from . import gpiosim
-from datetime import timedelta
from gpiod.line import Direction, Edge, Bias, Drive, Value, Clock
from unittest import TestCase
settings.direction = Direction.INPUT
settings.edge_detection = Edge.BOTH
settings.bias = Bias.DISABLED
- settings.debounce_period = timedelta(microseconds=3000)
+ settings.debounce_period = datetime.timedelta(microseconds=3000)
settings.event_clock = Clock.HTE
self.assertEqual(settings.direction, Direction.INPUT)
def test_repr(self):
self.assertEqual(
repr(self.settings),
- "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)",
+ "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)",
)
+ cmp = eval(repr(self.settings))
+ self.assertEqual(self.settings, cmp)
+
def test_str(self):
self.assertEqual(
str(self.settings),