File tree 3 files changed +3
-27
lines changed
3 files changed +3
-27
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ def files(package: Package) -> Traversable:
18
18
"""
19
19
Get a Traversable resource from a package
20
20
"""
21
- return from_package (get_package (package ))
21
+ return from_package (resolve (package ))
22
22
23
23
24
24
def get_resource_reader (package : types .ModuleType ) -> Optional [ResourceReader ]:
@@ -47,17 +47,6 @@ def _(cand: str):
47
47
return importlib .import_module (cand )
48
48
49
49
50
- def get_package (package : Package ) -> types .ModuleType :
51
- """Take a package name or module object and return the module.
52
-
53
- Raise an exception if the resolved module is not a package.
54
- """
55
- resolved = resolve (package )
56
- if wrap_spec (resolved ).submodule_search_locations is None :
57
- raise TypeError (f'{ package !r} is not a package' )
58
- return resolved
59
-
60
-
61
50
def from_package (package ):
62
51
"""
63
52
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