Issue #15576: Allow extension modules to be a package's __init__

module again. Also took the opportunity to stop accidentally exporting
_imp.extension_suffixes() as public.
This commit is contained in:
Brett Cannon 2012-08-10 13:47:54 -04:00
parent f4dc9204cc
commit ac9f2f3de3
13 changed files with 3700 additions and 3688 deletions

View file

@ -3,6 +3,7 @@ from . import util as ext_util
from .. import abc
from .. import util
import os.path
import sys
import unittest
@ -38,11 +39,11 @@ class LoaderTests(abc.LoaderTests):
machinery.ExtensionFileLoader)
def test_package(self):
# Extensions are not found in packages.
# No extension module as __init__ available for testing.
pass
def test_lacking_parent(self):
# Extensions are not found in packages.
# No extension module in a package available for testing.
pass
def test_module_reuse(self):
@ -61,6 +62,13 @@ class LoaderTests(abc.LoaderTests):
self.load_module(name)
self.assertEqual(cm.exception.name, name)
def test_is_package(self):
self.assertFalse(self.loader.is_package(ext_util.NAME))
for suffix in machinery.EXTENSION_SUFFIXES:
path = os.path.join('some', 'path', 'pkg', '__init__' + suffix)
loader = machinery.ExtensionFileLoader('pkg', path)
self.assertTrue(loader.is_package('pkg'))
def test_main():
from test.support import run_unittest