summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/builtin/test_finder.py
blob: ef8e8fe67ab526d99f571d284a814c2fa1eac766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from importlib import machinery
from .. import abc
from .. import util
from . import util as builtin_util

import sys
import unittest

class FinderTests(abc.FinderTests):

    """Test find_module() for built-in modules."""

    def test_module(self):
        # Common case.
        with util.uncache(builtin_util.NAME):
            found = machinery.BuiltinImporter.find_module(builtin_util.NAME)
            self.assert_(found)

    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)

    def test_ignore_path(self):
        # The value for 'path' should always trigger a failed import.
        with util.uncache(builtin_util.NAME):
            loader = machinery.BuiltinImporter.find_module(builtin_util.NAME,
                                                            ['pkg'])
            self.assert_(loader is None)



def test_main():
    from test.support import run_unittest
    run_unittest(FinderTests)


if __name__ == '__main__':
    test_main()