mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-98139: enhance namespace package repr
This commit is contained in:
parent
2db55e0c00
commit
bd221c01dd
3 changed files with 7 additions and 1 deletions
|
@ -580,7 +580,7 @@ def _module_repr_from_spec(spec):
|
|||
if spec.loader is None:
|
||||
return f'<module {name!r}>'
|
||||
else:
|
||||
return f'<module {name!r} ({spec.loader!r})>'
|
||||
return f'<module {name!r} (namespace) from {list(spec.loader._path)}>'
|
||||
else:
|
||||
if spec.has_location:
|
||||
return f'<module {name!r} from {spec.origin!r}>'
|
||||
|
|
|
@ -79,6 +79,10 @@ class SingleNamespacePackage(NamespacePackageTest):
|
|||
with self.assertRaises(ImportError):
|
||||
import foo.two
|
||||
|
||||
def test_simple_repr(self):
|
||||
import foo.one
|
||||
assert repr(foo).startswith("<module 'foo' (namespace) from [")
|
||||
|
||||
|
||||
class DynamicPathNamespacePackage(NamespacePackageTest):
|
||||
paths = ['portion1']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue