mirror of
https://github.com/python/cpython.git
synced 2025-10-10 08:53:14 +00:00
bpo-32303 - Consistency fixes for namespace loaders (GH-5481) (#5503)
* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.
https://bugs.python.org/issue32303
https://bugs.python.org/issue32305
(cherry picked from commit bbbcf8693b
)
Co-authored-by: Barry Warsaw <barry@python.org>
This commit is contained in:
parent
2b5937ec0a
commit
a23d30f64b
10 changed files with 1478 additions and 1436 deletions
|
@ -305,6 +305,7 @@ class ReloadTests:
|
|||
expected = {'__name__': name,
|
||||
'__package__': name,
|
||||
'__doc__': None,
|
||||
'__file__': None,
|
||||
}
|
||||
os.mkdir(name)
|
||||
with open(bad_path, 'w') as init_file:
|
||||
|
@ -316,8 +317,9 @@ class ReloadTests:
|
|||
spec = ns.pop('__spec__')
|
||||
ns.pop('__builtins__', None) # An implementation detail.
|
||||
self.assertEqual(spec.name, name)
|
||||
self.assertIs(spec.loader, None)
|
||||
self.assertIsNot(loader, None)
|
||||
self.assertIsNotNone(spec.loader)
|
||||
self.assertIsNotNone(loader)
|
||||
self.assertEqual(spec.loader, loader)
|
||||
self.assertEqual(set(path),
|
||||
set([os.path.dirname(bad_path)]))
|
||||
with self.assertRaises(AttributeError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue