diff --git a/bindings/python/tests/__init__.py b/bindings/python/tests/__init__.py
index 02f4e8d59c9aa426ca23a8ff2be4aa8aed8784c2..2374e8155373efbd94d5c66dcfdffa7cc23be9f6 100644
--- a/bindings/python/tests/__init__.py
+++ b/bindings/python/tests/__init__.py
@@ -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")
diff --git a/bindings/python/tests/__main__.py b/bindings/python/tests/__main__.py
index ea4143f53de5ac7d6202508216c7021ad3673b37..8b4260dfeeb39495b9b98fb096f8d3559e7ad7d3 100644
--- a/bindings/python/tests/__main__.py
+++ b/bindings/python/tests/__main__.py
@@ -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")
 
diff --git a/bindings/python/tests/gpiosim/__init__.py b/bindings/python/tests/gpiosim/__init__.py
index f65e413a6e8a578607f24c179f34308228dd5cea..64a15511df70863a14e134c1986ea625f4701dd6 100644
--- a/bindings/python/tests/gpiosim/__init__.py
+++ b/bindings/python/tests/gpiosim/__init__.py
@@ -2,3 +2,5 @@
 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
 
 from .chip import Chip
+
+__all__ = ["Chip"]
diff --git a/bindings/python/tests/gpiosim/chip.py b/bindings/python/tests/gpiosim/chip.py
index 6af883ee3152aee2976e674647a218d34d4dbf7e..691bfe13084b3fcc109dffc64866fb901d7d8069 100644
--- a/bindings/python/tests/gpiosim/chip.py
+++ b/bindings/python/tests/gpiosim/chip.py
@@ -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:
     """
diff --git a/bindings/python/tests/procname/__init__.py b/bindings/python/tests/procname/__init__.py
index af6abdd2586a95c83234ac9a6f445e3e33e71866..436ff406fec30f7711dd1bb3f95024a6c530d45a 100644
--- a/bindings/python/tests/procname/__init__.py
+++ b/bindings/python/tests/procname/__init__.py
@@ -2,3 +2,5 @@
 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
 
 from ._ext import set_process_name
+
+__all__ = ["set_process_name"]
diff --git a/bindings/python/tests/tests_chip.py b/bindings/python/tests/tests_chip.py
index bd4ae34cd618a972417e314b36ed527675627fbc..9110bebf3596557fbacb3c7620e931982f9dc957 100644
--- a/bindings/python/tests/tests_chip.py
+++ b/bindings/python/tests/tests_chip.py
@@ -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):
diff --git a/bindings/python/tests/tests_chip_info.py b/bindings/python/tests/tests_chip_info.py
index d392ec3beaf027326ae91952b917f0d6aae61fd0..9474f38be3d33e60529e0e24fb4f10cb99ce9d5c 100644
--- a/bindings/python/tests/tests_chip_info.py
+++ b/bindings/python/tests/tests_chip_info.py
@@ -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):
diff --git a/bindings/python/tests/tests_edge_event.py b/bindings/python/tests/tests_edge_event.py
index 68ab17eae7be301cbca8d6d83f90a03df0aeea53..7e7fada38cf2a983172aaa9c8400fbfe0d3b7a7d 100644
--- a/bindings/python/tests/tests_edge_event.py
+++ b/bindings/python/tests/tests_edge_event.py
@@ -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
 
diff --git a/bindings/python/tests/tests_info_event.py b/bindings/python/tests/tests_info_event.py
index a226e52a282347f7514a46f854a9dd5a06a50be8..bbdbc0fa6e69c59a32d67d00f5e785105c90e840 100644
--- a/bindings/python/tests/tests_info_event.py
+++ b/bindings/python/tests/tests_info_event.py
@@ -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
 
 
diff --git a/bindings/python/tests/tests_line.py b/bindings/python/tests/tests_line.py
index 70aa09bda2033bab7d7e59ea4ff48b2b783da468..218256711b2b248f692f07b9ae99e462f03c6965 100644
--- a/bindings/python/tests/tests_line.py
+++ b/bindings/python/tests/tests_line.py
@@ -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):
diff --git a/bindings/python/tests/tests_line_info.py b/bindings/python/tests/tests_line_info.py
index 2779e7a7353c95b35f78ab96311a418af41ffdbc..79281a82932a32bdb8c89f2aac7b15eb28eafd9d 100644
--- a/bindings/python/tests/tests_line_info.py
+++ b/bindings/python/tests/tests_line_info.py
@@ -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)}
diff --git a/bindings/python/tests/tests_line_request.py b/bindings/python/tests/tests_line_request.py
index 285c9f1e6f43c9623880e91923b0019575adf768..c3e86c56be63f7e449c07e7833cb7080ee42b0ac 100644
--- a/bindings/python/tests/tests_line_request.py
+++ b/bindings/python/tests/tests_line_request.py
@@ -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
diff --git a/bindings/python/tests/tests_line_settings.py b/bindings/python/tests/tests_line_settings.py
index 83be3d9a90b9391ffe9cb3fb09c1a4a2042468c6..832ac8a2377ddb25f5a5ab5c1732d1a9d5c5dff1 100644
--- a/bindings/python/tests/tests_line_settings.py
+++ b/bindings/python/tests/tests_line_settings.py
@@ -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):
diff --git a/bindings/python/tests/tests_module.py b/bindings/python/tests/tests_module.py
index c6f07a618b2c19e6afae9b1bf48747b086c8919a..f46729feda86962d17907bc8b6b4e710fec3087e 100644
--- a/bindings/python/tests/tests_module.py
+++ b/bindings/python/tests/tests_module.py
@@ -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):
