mirror of
https://github.com/python/cpython.git
synced 2025-10-28 04:04:44 +00:00
Issue #16803: Move test.test_importlib.extension to use both frozen and source importlib code
This commit is contained in:
parent
6a4cbc00ab
commit
e38b0544c4
4 changed files with 44 additions and 44 deletions
|
|
@ -1,31 +1,32 @@
|
|||
from importlib import machinery
|
||||
from .. import util as test_util
|
||||
from . import util
|
||||
|
||||
machinery = test_util.import_importlib('importlib.machinery')
|
||||
|
||||
import collections
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
class PathHookTests(unittest.TestCase):
|
||||
class PathHookTests:
|
||||
|
||||
"""Test the path hook for extension modules."""
|
||||
# XXX Should it only succeed for pre-existing directories?
|
||||
# XXX Should it only work for directories containing an extension module?
|
||||
|
||||
def hook(self, entry):
|
||||
return machinery.FileFinder.path_hook((machinery.ExtensionFileLoader,
|
||||
machinery.EXTENSION_SUFFIXES))(entry)
|
||||
return self.machinery.FileFinder.path_hook(
|
||||
(self.machinery.ExtensionFileLoader,
|
||||
self.machinery.EXTENSION_SUFFIXES))(entry)
|
||||
|
||||
def test_success(self):
|
||||
# Path hook should handle a directory where a known extension module
|
||||
# exists.
|
||||
self.assertTrue(hasattr(self.hook(util.PATH), 'find_module'))
|
||||
|
||||
|
||||
def test_main():
|
||||
from test.support import run_unittest
|
||||
run_unittest(PathHookTests)
|
||||
Frozen_PathHooksTests, Source_PathHooksTests = test_util.test_both(
|
||||
PathHookTests, machinery=machinery)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_main()
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue