Python importlib 模块,_bootstrap() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用importlib._bootstrap()

项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_frozen_importlib_is_bootstrap(self):
        from importlib import _bootstrap
        mod = sys.modules['_frozen_importlib']
        self.assertIs(mod, _bootstrap)
        self.assertEqual(mod.__name__, 'importlib._bootstrap')
        self.assertEqual(mod.__package__, 'importlib')
        self.assertTrue(mod.__file__.endswith('_bootstrap.py'), mod.__file__)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_get_sourcefile(self):
        # Given a valid bytecode path, return the path to the corresponding
        # source file if it exists.
        with mock.patch('importlib._bootstrap._path_isfile') as _path_isfile:
            _path_isfile.return_value = True;
            path = TESTFN + '.pyc'
            expect = TESTFN + '.py'
            self.assertEqual(_get_sourcefile(path), expect)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_get_sourcefile_no_source(self):
        # Given a valid bytecode path without a corresponding source path,
        # return the original bytecode path.
        with mock.patch('importlib._bootstrap._path_isfile') as _path_isfile:
            _path_isfile.return_value = False;
            path = TESTFN + '.pyc'
            self.assertEqual(_get_sourcefile(path), path)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_frozen_importlib_is_bootstrap(self):
        from importlib import _bootstrap
        mod = sys.modules['_frozen_importlib']
        self.assertIs(mod, _bootstrap)
        self.assertEqual(mod.__name__, 'importlib._bootstrap')
        self.assertEqual(mod.__package__, 'importlib')
        self.assertTrue(mod.__file__.endswith('_bootstrap.py'), mod.__file__)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_get_sourcefile(self):
        # Given a valid bytecode path, return the path to the corresponding
        # source file if it exists.
        with mock.patch('importlib._bootstrap._path_isfile') as _path_isfile:
            _path_isfile.return_value = True;
            path = TESTFN + '.pyc'
            expect = TESTFN + '.py'
            self.assertEqual(_get_sourcefile(path), expect)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_get_sourcefile_no_source(self):
        # Given a valid bytecode path without a corresponding source path,
        # return the original bytecode path.
        with mock.patch('importlib._bootstrap._path_isfile') as _path_isfile:
            _path_isfile.return_value = False;
            path = TESTFN + '.pyc'
            self.assertEqual(_get_sourcefile(path), path)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_frozen_importlib_is_bootstrap(self):
        from importlib import _bootstrap
        mod = sys.modules['_frozen_importlib']
        self.assertIs(mod, _bootstrap)
        self.assertEqual(mod.__name__, 'importlib._bootstrap')
        self.assertEqual(mod.__package__, 'importlib')
        self.assertTrue(mod.__file__.endswith('_bootstrap.py'), mod.__file__)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_get_sourcefile(self):
        # Given a valid bytecode path, return the path to the corresponding
        # source file if it exists.
        with mock.patch('importlib._bootstrap._path_isfile') as _path_isfile:
            _path_isfile.return_value = True;
            path = TESTFN + '.pyc'
            expect = TESTFN + '.py'
            self.assertEqual(_get_sourcefile(path), expect)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_get_sourcefile_no_source(self):
        # Given a valid bytecode path without a corresponding source path,
        # return the original bytecode path.
        with mock.patch('importlib._bootstrap._path_isfile') as _path_isfile:
            _path_isfile.return_value = False;
            path = TESTFN + '.pyc'
            self.assertEqual(_get_sourcefile(path), path)