Python importlib._bootstrap() Examples

The following are 3 code examples of importlib._bootstrap(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module importlib , or try the search function .
Example #1
Source File: test_import.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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__) 
Example #2
Source File: test_import.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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) 
Example #3
Source File: test_import.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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)