Skip to content

Commit

Permalink
Use bytes ranges instead of bytes literals.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 25, 2024
1 parent d98c558 commit 76145e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion importlib_resources/tests/test_open.py
Expand Up @@ -24,7 +24,7 @@ def test_open_binary(self):
target = resources.files(self.data) / 'binary.file'
with target.open('rb') as fp:
result = fp.read()
self.assertEqual(result, b'\x00\x01\x02\x03')
self.assertEqual(result, bytes(range(4)))

def test_open_text_default_encoding(self):
target = resources.files(self.data) / 'utf-8.file'
Expand Down
10 changes: 5 additions & 5 deletions importlib_resources/tests/test_read.py
Expand Up @@ -19,7 +19,7 @@ def execute(self, package, path):
class ReadTests:
def test_read_bytes(self):
result = resources.files(self.data).joinpath('binary.file').read_bytes()
self.assertEqual(result, b'\0\1\2\3')
self.assertEqual(result, bytes(range(4)))

def test_read_text_default_encoding(self):
result = (
Expand Down Expand Up @@ -60,13 +60,13 @@ class ReadZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
def test_read_submodule_resource(self):
submodule = import_module('data01.subdirectory')
result = resources.files(submodule).joinpath('binary.file').read_bytes()
self.assertEqual(result, b'\4\5\6\x07')
self.assertEqual(result, bytes(range(4, 8)))

def test_read_submodule_resource_by_name(self):
result = (
resources.files('data01.subdirectory').joinpath('binary.file').read_bytes()
)
self.assertEqual(result, b'\4\5\6\x07')
self.assertEqual(result, bytes(range(4, 8)))


class ReadNamespaceTests(ReadTests, unittest.TestCase):
Expand All @@ -82,15 +82,15 @@ class ReadNamespaceZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
def test_read_submodule_resource(self):
submodule = import_module('namespacedata01.subdirectory')
result = resources.files(submodule).joinpath('binary.file').read_bytes()
self.assertEqual(result, b'\x0c\x0d\x0e\x0f')
self.assertEqual(result, bytes(range(12, 16)))

def test_read_submodule_resource_by_name(self):
result = (
resources.files('namespacedata01.subdirectory')
.joinpath('binary.file')
.read_bytes()
)
self.assertEqual(result, b'\x0c\x0d\x0e\x0f')
self.assertEqual(result, bytes(range(12, 16)))


if __name__ == '__main__':
Expand Down

0 comments on commit 76145e2

Please sign in to comment.