Issue #19721: Consolidate test_importlib utility code into a single

module.
This commit is contained in:
Brett Cannon 2014-05-09 14:32:57 -04:00
parent 91795c8e34
commit 732ac654c8
25 changed files with 249 additions and 270 deletions

View file

@ -1,8 +1,7 @@
from .. import abc
from .. import util as test_util
from . import util
from .. import util
machinery = test_util.import_importlib('importlib.machinery')
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
@ -14,7 +13,7 @@ class FinderTests(abc.FinderTests):
"""Test the finder for extension modules."""
def find_module(self, fullname):
importer = self.machinery.FileFinder(util.PATH,
importer = self.machinery.FileFinder(util.EXTENSIONS.path,
(self.machinery.ExtensionFileLoader,
self.machinery.EXTENSION_SUFFIXES))
with warnings.catch_warnings():
@ -22,7 +21,7 @@ class FinderTests(abc.FinderTests):
return importer.find_module(fullname)
def test_module(self):
self.assertTrue(self.find_module(util.NAME))
self.assertTrue(self.find_module(util.EXTENSIONS.name))
# No extension module as an __init__ available for testing.
test_package = test_package_in_package = None
@ -36,7 +35,7 @@ class FinderTests(abc.FinderTests):
def test_failure(self):
self.assertIsNone(self.find_module('asdfjkl;'))
Frozen_FinderTests, Source_FinderTests = test_util.test_both(
Frozen_FinderTests, Source_FinderTests = util.test_both(
FinderTests, machinery=machinery)