@@ -2,8 +2,6 @@
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
import os
-import unittest
-
from distutils.version import LooseVersion
required_kernel_version = LooseVersion("5.19.0")
@@ -4,17 +4,16 @@
import unittest
+from . import procname
from .tests_chip import *
from .tests_chip_info import *
from .tests_edge_event import *
from .tests_info_event import *
from .tests_line import *
from .tests_line_info import *
+from .tests_line_request import *
from .tests_line_settings import *
from .tests_module import *
-from .tests_line_request import *
-
-from . import procname
procname.set_process_name("python-gpiod")
@@ -2,3 +2,5 @@
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
from .chip import Chip
+
+__all__ = ["Chip"]
@@ -1,10 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-from . import _ext
from enum import Enum
from typing import Optional
+from . import _ext
+
class Chip:
"""
@@ -2,3 +2,5 @@
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
from ._ext import set_process_name
+
+__all__ = ["set_process_name"]
@@ -2,12 +2,13 @@
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
import errno
-import gpiod
import os
+from unittest import TestCase
+
+import gpiod
from . import gpiosim
from .helpers import LinkGuard
-from unittest import TestCase
class ChipConstructor(TestCase):
@@ -1,10 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
+from unittest import TestCase
+
import gpiod
from . import gpiosim
-from unittest import TestCase
class ChipInfoProperties(TestCase):
@@ -1,16 +1,17 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-import gpiod
import time
-
-from . import gpiosim
from datetime import timedelta
from functools import partial
-from gpiod.line import Direction, Edge
from threading import Thread
from unittest import TestCase
+import gpiod
+from gpiod.line import Direction, Edge
+
+from . import gpiosim
+
EventType = gpiod.EdgeEvent.Type
Pull = gpiosim.Chip.Pull
@@ -3,17 +3,17 @@
import datetime
import errno
-import gpiod
import threading
import time
-import unittest
-
-from . import gpiosim
from dataclasses import FrozenInstanceError
from functools import partial
-from gpiod.line import Direction
from unittest import TestCase
+import gpiod
+from gpiod.line import Direction
+
+from . import gpiosim
+
EventType = gpiod.InfoEvent.Type
@@ -1,9 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-FileCopyrightText: 2024 Kent Gibson <warthog618@gmail.com>
-from gpiod.line import Value
from unittest import TestCase
+from gpiod.line import Value
+
class LineValue(TestCase):
def test_cast_bool(self):
@@ -1,17 +1,17 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-import errno
+from unittest import TestCase
+
import gpiod
-import unittest
+from gpiod.line import Bias, Clock, Direction, Drive
from . import gpiosim
-from gpiod.line import Direction, Bias, Drive, Clock
HogDir = gpiosim.Chip.Direction
-class GetLineInfo(unittest.TestCase):
+class GetLineInfo(TestCase):
def setUp(self):
self.sim = gpiosim.Chip(
num_lines=4,
@@ -49,7 +49,7 @@ class GetLineInfo(unittest.TestCase):
self.chip.get_line_info()
-class LinePropertiesCanBeRead(unittest.TestCase):
+class LinePropertiesCanBeRead(TestCase):
def test_basic_properties(self):
sim = gpiosim.Chip(
num_lines=8,
@@ -86,7 +86,7 @@ class LinePropertiesCanBeRead(unittest.TestCase):
self.assertEqual(info6.debounce_period.total_seconds(), 0.0)
-class LineInfoStringRepresentation(unittest.TestCase):
+class LineInfoStringRepresentation(TestCase):
def test_line_info_str(self):
sim = gpiosim.Chip(
line_names={0: "foo"}, hogs={0: ("hogger", HogDir.OUTPUT_HIGH)}
@@ -1,12 +1,12 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-import errno
+from unittest import TestCase
+
import gpiod
+from gpiod.line import Clock, Direction, Drive, Edge, Value
from . import gpiosim
-from gpiod.line import Clock, Direction, Drive, Edge, Value
-from unittest import TestCase
Pull = gpiosim.Chip.Pull
SimVal = gpiosim.Chip.Value
@@ -2,12 +2,11 @@
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
import datetime
-import gpiod
-
-from . import gpiosim
-from gpiod.line import Direction, Edge, Bias, Drive, Value, Clock
from unittest import TestCase
+import gpiod
+from gpiod.line import Bias, Clock, Direction, Drive, Edge, Value
+
class LineSettingsConstructor(TestCase):
def test_default_values(self):
@@ -1,13 +1,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-import gpiod
import os
-import unittest
+from unittest import TestCase
+
+import gpiod
from . import gpiosim
from .helpers import LinkGuard
-from unittest import TestCase
class IsGPIOChip(TestCase):
@@ -50,7 +50,6 @@ class IsGPIOChip(TestCase):
class VersionString(TestCase):
-
VERSION_PATTERN = "^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)?$"
def test_api_version_string(self):
Remove unused imports and sort the remainder following isort rules. Update the submodules to use `__all__` to advertise available imports. Remove an unnecessary blank line in the VersionString class to abide by the ruff formatter's rules (compatible with black's formatting). Signed-off-by: Vincent Fazio <vfazio@xes-inc.com> --- bindings/python/tests/__init__.py | 2 -- bindings/python/tests/__main__.py | 5 ++--- bindings/python/tests/gpiosim/__init__.py | 2 ++ bindings/python/tests/gpiosim/chip.py | 3 ++- bindings/python/tests/procname/__init__.py | 2 ++ bindings/python/tests/tests_chip.py | 5 +++-- bindings/python/tests/tests_chip_info.py | 3 ++- bindings/python/tests/tests_edge_event.py | 9 +++++---- bindings/python/tests/tests_info_event.py | 10 +++++----- bindings/python/tests/tests_line.py | 3 ++- bindings/python/tests/tests_line_info.py | 12 ++++++------ bindings/python/tests/tests_line_request.py | 6 +++--- bindings/python/tests/tests_line_settings.py | 7 +++---- bindings/python/tests/tests_module.py | 7 +++---- 14 files changed, 40 insertions(+), 36 deletions(-)