2009-01-22 23:43:07 +01:00
|
|
|
from importlib import machinery
|
2009-01-18 01:24:28 +01:00
|
|
|
from .. import support
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
class FinderTests(unittest.TestCase):
|
|
|
|
|
|
|
|
"""Test find_module() for built-in modules."""
|
|
|
|
|
|
|
|
assert 'errno' in sys.builtin_module_names
|
|
|
|
name = 'errno'
|
|
|
|
|
|
|
|
find_module = staticmethod(lambda name, path=None:
|
2009-01-22 23:43:07 +01:00
|
|
|
machinery.BuiltinImporter.find_module(name, path))
|
2009-01-18 01:24:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_find_module(self):
|
|
|
|
# Common case.
|
|
|
|
with support.uncache(self.name):
|
|
|
|
self.assert_(self.find_module(self.name))
|
|
|
|
|
|
|
|
def test_ignore_path(self):
|
|
|
|
# The value for 'path' should always trigger a failed import.
|
|
|
|
with support.uncache(self.name):
|
|
|
|
self.assert_(self.find_module(self.name, ['pkg']) is None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_main():
|
|
|
|
from test.support import run_unittest
|
|
|
|
run_unittest(FinderTests)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|