@@ -62,6 +62,9 @@ def create_package(file, path, is_package=True, contents=()):
62
62
63
63
64
64
class CommonTests (metaclass = abc .ABCMeta ):
65
+ """
66
+ Tests shared by test_open, test_path, and test_read.
67
+ """
65
68
@abc .abstractmethod
66
69
def execute (self , package , path ):
67
70
"""
@@ -115,14 +118,21 @@ def test_non_package_by_package(self):
115
118
module = sys .modules ['importlib_resources.tests.util' ]
116
119
self .execute (module , 'utf-8.file' )
117
120
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.
119
125
bytes_data = io .BytesIO (b'Hello, world!' )
120
126
package = create_package (file = bytes_data , path = FileNotFoundError ())
121
127
self .execute (package , 'utf-8.file' )
122
128
self .assertEqual (package .__loader__ ._path , 'utf-8.file' )
123
129
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.
125
134
bytes_data = io .BytesIO (b'Hello, world!' )
135
+ # any path that exists
126
136
path = __file__
127
137
package = create_package (file = bytes_data , path = path )
128
138
self .execute (package , 'utf-8.file' )
0 commit comments