Skip to content

Commit e1a0b90

Browse files
committed
Expand docstrings and faux-docstrings (boo unittest) to explain purpose of a couple of tests. Rename tests to reflect a more precise purpose.
1 parent 0b35342 commit e1a0b90

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

importlib_resources/tests/util.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def create_package(file, path, is_package=True, contents=()):
6262

6363

6464
class CommonTests(metaclass=abc.ABCMeta):
65+
"""
66+
Tests shared by test_open, test_path, and test_read.
67+
"""
6568
@abc.abstractmethod
6669
def execute(self, package, path):
6770
"""
@@ -115,14 +118,21 @@ def test_non_package_by_package(self):
115118
module = sys.modules['importlib_resources.tests.util']
116119
self.execute(module, 'utf-8.file')
117120

118-
def test_resource_opener(self):
121+
def test_missing_path(self):
122+
# Attempting to open or read or request the path for a
123+
# non-existent path should succeed if open_resource
124+
# can return a viable data stream.
119125
bytes_data = io.BytesIO(b'Hello, world!')
120126
package = create_package(file=bytes_data, path=FileNotFoundError())
121127
self.execute(package, 'utf-8.file')
122128
self.assertEqual(package.__loader__._path, 'utf-8.file')
123129

124-
def test_resource_path(self):
130+
def test_extant_path(self):
131+
# Attempting to open or read or request the path when the
132+
# path does exist should still succeed. Does not assert
133+
# anything about the result.
125134
bytes_data = io.BytesIO(b'Hello, world!')
135+
# any path that exists
126136
path = __file__
127137
package = create_package(file=bytes_data, path=path)
128138
self.execute(package, 'utf-8.file')

0 commit comments

Comments
 (0)