File tree 3 files changed +3
-28
lines changed
3 files changed +3
-28
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def files(package):
19
19
"""
20
20
Get a Traversable resource from a package
21
21
"""
22
- return from_package (get_package (package ))
22
+ return from_package (resolve (package ))
23
23
24
24
25
25
def get_resource_reader (package ):
@@ -44,18 +44,6 @@ def resolve(cand):
44
44
return cand if isinstance (cand , types .ModuleType ) else importlib .import_module (cand )
45
45
46
46
47
- def get_package (package ):
48
- # type: (Package) -> types.ModuleType
49
- """Take a package name or module object and return the module.
50
-
51
- Raise an exception if the resolved module is not a package.
52
- """
53
- resolved = resolve (package )
54
- if wrap_spec (resolved ).submodule_search_locations is None :
55
- raise TypeError (f'{ package !r} is not a package' )
56
- return resolved
57
-
58
-
59
47
def from_package (package ):
60
48
"""
61
49
Return a Traversable object for the given package.
Original file line number Diff line number Diff line change @@ -64,10 +64,8 @@ def test_module_resources(self):
64
64
_path .build (spec , self .site_dir )
65
65
import mod
66
66
67
- # currently a failure occurs; ref #203
68
- with self .assertRaisesRegex (TypeError , '.*mod.* is not a package' ):
69
- actual = resources .files (mod ).joinpath ('res.txt' ).read_text ()
70
- assert actual == spec ['res.txt' ]
67
+ actual = resources .files (mod ).joinpath ('res.txt' ).read_text ()
68
+ assert actual == spec ['res.txt' ]
71
69
72
70
73
71
if __name__ == '__main__' :
Original file line number Diff line number Diff line change @@ -102,17 +102,6 @@ def test_importing_module_as_side_effect(self):
102
102
del sys .modules [data01 .__name__ ]
103
103
self .execute (data01 .__name__ , 'utf-8.file' )
104
104
105
- def test_non_package_by_name (self ):
106
- # The anchor package cannot be a module.
107
- with self .assertRaises (TypeError ):
108
- self .execute (__name__ , 'utf-8.file' )
109
-
110
- def test_non_package_by_package (self ):
111
- # The anchor package cannot be a module.
112
- with self .assertRaises (TypeError ):
113
- module = sys .modules ['importlib_resources.tests.util' ]
114
- self .execute (module , 'utf-8.file' )
115
-
116
105
def test_missing_path (self ):
117
106
# Attempting to open or read or request the path for a
118
107
# non-existent path should succeed if open_resource
You can’t perform that action at this time.
0 commit comments