8000 gh-59110: zipimport: support namespace packages when no directory entry exists by serhiy-storchaka · Pull Request #121233 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-59110: zipimport: support namespace packages when no directory entry exists #121233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test_importlib.
  • Loading branch information
serhiy-storchaka committed Jul 1, 2024
commit 1b645b7a061068f34f8c6acd63fe2c38d915ca15
27 changes: 13 additions & 14 deletions Lib/test/test_importlib/test_namespace_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,24 @@ def test_project3_succeeds(self):

class ZipWithMissingDirectory(NamespacePackageTest):
paths = ['missing_directory.zip']
# missing_directory.zip contains:
# Length Date Time Name
# --------- ---------- ----- ----
# 29 2012-05-03 18:13 foo/one.py
# 0 2012-05-03 20:57 bar/
# 38 2012-05-03 20:57 bar/two.py
# --------- -------
# 67 3 files

@unittest.expectedFailure
def test_missing_directory(self):
# This will fail because missing_directory.zip contains:
# Length Date Time Name
# --------- ---------- ----- ----
# 29 2012-05-03 18:13 foo/one.py
# 0 2012-05-03 20:57 bar/
# 38 2012-05-03 20:57 bar/two.py
# --------- -------
# 67 3 files

# Because there is no 'foo/', the zipimporter currently doesn't
# know that foo is a namespace package

import foo.one
self.assertEqual(foo.one.attr, 'portion1 foo one')

def test_missing_directory2(self):
import foo
self.assertFalse(hasattr(foo, 'one'))

def test_present_directory(self):
# This succeeds because there is a "bar/" in the zip file
import bar.two
self.assertEqual(bar.two.attr, 'missing_directory foo two')

Expand Down
2924
0