From 558f5bf9f266998e616deaf8a9d373da37b33054 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 21 Mar 2024 10:52:42 +0100 Subject: [PATCH] Formatting nitpicks --- importlib_resources/functional.py | 4 ++-- importlib_resources/tests/test_functional.py | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/importlib_resources/functional.py b/importlib_resources/functional.py index 9f01680..9e3ea15 100644 --- a/importlib_resources/functional.py +++ b/importlib_resources/functional.py @@ -1,5 +1,4 @@ -"""Simplified function-based API for importlib.resources -""" +"""Simplified function-based API for importlib.resources""" import warnings @@ -8,6 +7,7 @@ _MISSING = object() + def open_binary(anchor, *path_names): """Open for binary reading the *resource* within *package*.""" return _get_resource(anchor, path_names).open('rb') diff --git a/importlib_resources/tests/test_functional.py b/importlib_resources/tests/test_functional.py index 9a9b4e1..f359900 100644 --- a/importlib_resources/tests/test_functional.py +++ b/importlib_resources/tests/test_functional.py @@ -20,7 +20,7 @@ class ModuleAnchorMixin: from . import data02 as anchor02 -class FunctionalAPIBase(): +class FunctionalAPIBase: def _gen_resourcetxt_path_parts(self): """Yield various names of a text file in anchor02, each in a subTest """ @@ -61,18 +61,21 @@ def test_read_text(self): resources.read_text(self.anchor01, 'utf-16.file') self.assertEqual( resources.read_text( - self.anchor01, 'binary.file', encoding='latin1', + self.anchor01, + 'binary.file', + encoding='latin1', ), '\x00\x01\x02\x03', ) self.assertEqual( resources.read_text( - self.anchor01, 'utf-16.file', + self.anchor01, + 'utf-16.file', errors='backslashreplace', ), 'Hello, UTF-16 world!\n'.encode('utf-16').decode( errors='backslashreplace', - ) + ), ) def test_read_binary(self): @@ -105,18 +108,21 @@ def test_open_text(self): with self.assertRaises(UnicodeDecodeError): f.read() with resources.open_text( - self.anchor01, 'binary.file', encoding='latin1', + self.anchor01, + 'binary.file', + encoding='latin1', ) as f: self.assertEqual(f.read(), '\x00\x01\x02\x03') with resources.open_text( - self.anchor01, 'utf-16.file', + self.anchor01, + 'utf-16.file', errors='backslashreplace', ) as f: self.assertEqual( f.read(), 'Hello, UTF-16 world!\n'.encode('utf-16').decode( errors='backslashreplace', - ) + ), ) def test_open_binary(self):