2009-01-22 18:43:07 -04:00
|
|
|
from importlib import machinery
|
2009-01-29 20:22:35 -04:00
|
|
|
from .. import abc
|
2009-01-17 20:24:28 -04:00
|
|
|
from .. import support
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
2009-01-29 20:22:35 -04:00
|
|
|
class FinderTests(abc.FinderTests):
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
"""Test find_module() for built-in modules."""
|
|
|
|
|
|
|
|
assert 'errno' in sys.builtin_module_names
|
|
|
|
name = 'errno'
|
|
|
|
|
2009-01-26 21:41:57 -04:00
|
|
|
def test_module(self):
|
2009-01-17 20:24:28 -04:00
|
|
|
# Common case.
|
|
|
|
with support.uncache(self.name):
|
2009-01-26 21:41:57 -04:00
|
|
|
self.assert_(machinery.BuiltinImporter.find_module(self.name))
|
|
|
|
|
|
|
|
def test_package(self):
|
|
|
|
# Built-in modules cannot be a package.
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_module_in_package(self):
|
|
|
|
# Built-in modules cannobt be in a package.
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_package_in_package(self):
|
|
|
|
# Built-in modules cannot be a package.
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_package_over_module(self):
|
|
|
|
# Built-in modules cannot be a package.
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_failure(self):
|
|
|
|
assert 'importlib' not in sys.builtin_module_names
|
|
|
|
loader = machinery.BuiltinImporter.find_module('importlib')
|
|
|
|
self.assert_(loader is None)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
def test_ignore_path(self):
|
|
|
|
# The value for 'path' should always trigger a failed import.
|
|
|
|
with support.uncache(self.name):
|
2009-01-26 21:41:57 -04:00
|
|
|
loader = machinery.BuiltinImporter.find_module(self.name, ['pkg'])
|
|
|
|
self.assert_(loader is None)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_main():
|
|
|
|
from test.support import run_unittest
|
|
|
|
run_unittest(FinderTests)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|