summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/frozen/test_finder.py
blob: 254101978ecbf931a5f956b4f6e1b1a8a99cf6cb (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
import importlib
from ..builtin import test_finder
from .. import support

import unittest


class FinderTests(test_finder.FinderTests):

    """Test finding frozen modules."""

    def find(self, name, path=None):
        finder = importlib.FrozenImporter()
        return finder.find_module(name, path)


    def test_module(self):
        name = '__hello__'
        loader = self.find(name)
        self.assert_(hasattr(loader, 'load_module'))

    def test_package(self):
        loader = self.find('__phello__')
        self.assert_(hasattr(loader, 'load_module'))

    def test_module_in_package(self):
        loader = self.find('__phello__.spam', ['__phello__'])
        self.assert_(hasattr(loader, 'load_module'))

    def test_package_in_package(self):
        pass

    def test_failure(self):
        loader = self.find('<not real>')
        self.assert_(loader is None)


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


if __name__ == '__main__':
    test_main()