@@ -9,7 +9,5 @@ current_version = LooseVersion(os.uname().release.split("-")[0])
if current_version < required_kernel_version:
raise NotImplementedError(
- "linux kernel version must be at least {} - got {}".format(
- required_kernel_version, current_version
- )
+ f"linux kernel version must be at least {required_kernel_version} - got {current_version}"
)
@@ -26,7 +26,7 @@ class ChipConstructor(TestCase):
pass
def test_open_chip_by_link(self) -> None:
- link = "/tmp/gpiod-py-test-link.{}".format(os.getpid())
+ link = f"/tmp/gpiod-py-test-link.{os.getpid()}"
sim = gpiosim.Chip()
with LinkGuard(sim.dev_path, link):
@@ -96,7 +96,7 @@ class ChipProperties(TestCase):
class ChipDevPathFromLink(TestCase):
def test_dev_path_open_by_link(self) -> None:
sim = gpiosim.Chip()
- link = "/tmp/gpiod-py-test-link.{}".format(os.getpid())
+ link = f"/tmp/gpiod-py-test-link.{os.getpid()}"
with LinkGuard(sim.dev_path, link):
with gpiod.Chip(link) as chip:
@@ -206,7 +206,7 @@ class StringRepresentation(TestCase):
def test_repr(self) -> None:
assert self.sim
- self.assertEqual(repr(self.chip), 'gpiod.Chip("{}")'.format(self.sim.dev_path))
+ self.assertEqual(repr(self.chip), f'gpiod.Chip("{self.sim.dev_path}")')
cmp = eval(repr(self.chip))
self.assertEqual(self.chip.path, cmp.path)
@@ -216,9 +216,7 @@ class StringRepresentation(TestCase):
info = self.chip.get_info()
self.assertEqual(
str(self.chip),
- '<Chip path="{}" fd={} info=<ChipInfo name="{}" label="foobar" num_lines=4>>'.format(
- self.sim.dev_path, self.chip.fd, info.name
- ),
+ f'<Chip path="{self.sim.dev_path}" fd={self.chip.fd} info=<ChipInfo name="{info.name}" label="foobar" num_lines=4>>',
)
@@ -56,5 +56,5 @@ class ChipInfoStringRepresentation(TestCase):
self.assertEqual(
str(info),
- '<ChipInfo name="{}" label="foobar" num_lines=16>'.format(sim.name),
+ f'<ChipInfo name="{sim.name}" label="foobar" num_lines=16>',
)
@@ -635,9 +635,7 @@ class LineRequestStringRepresentation(TestCase):
with chip.request_lines(config={(2, 6, 4, 1): None}) as req:
self.assertEqual(
str(req),
- '<LineRequest chip="{}" num_lines=4 offsets=[2, 6, 4, 1] fd={}>'.format(
- self.sim.name, req.fd
- ),
+ f'<LineRequest chip="{self.sim.name}" num_lines=4 offsets=[2, 6, 4, 1] fd={req.fd}>',
)
def test_str_released(self) -> None:
@@ -36,14 +36,14 @@ class IsGPIOChip(TestCase):
self.assertTrue(gpiod.is_gpiochip_device(path=sim.dev_path))
def test_is_gpiochip_link_good(self) -> None:
- link = "/tmp/gpiod-py-test-link.{}".format(os.getpid())
+ link = f"/tmp/gpiod-py-test-link.{os.getpid()}"
sim = gpiosim.Chip()
with LinkGuard(sim.dev_path, link):
self.assertTrue(gpiod.is_gpiochip_device(link))
def test_is_gpiochip_link_bad(self) -> None:
- link = "/tmp/gpiod-py-test-link.{}".format(os.getpid())
+ link = f"/tmp/gpiod-py-test-link.{os.getpid()}"
with LinkGuard("/dev/null", link):
self.assertFalse(gpiod.is_gpiochip_device(link))
Signed-off-by: Vincent Fazio <vfazio@xes-inc.com> --- bindings/python/tests/__init__.py | 4 +--- bindings/python/tests/tests_chip.py | 10 ++++------ bindings/python/tests/tests_chip_info.py | 2 +- bindings/python/tests/tests_line_request.py | 4 +--- bindings/python/tests/tests_module.py | 4 ++-- 5 files changed, 9 insertions(+), 15 deletions(-)