test findspec for builtin modules def testmoduleself common case with util uncacheutil builtins goodname found self machinery builtinimporter findspecutil builtins goodname self asserttruefound self assertequalfound origin builtin builtin modules cannot be a package testpackage none builtin modules cannot be in a package testmoduleinpackage none builtin modules cannot be a package testpackageinpackage none builtin modules cannot be a package testpackageovermodule none def testfailureself name importlib assert name not in sys builtinmodulenames spec self machinery builtinimporter findspecname self assertisnonespec frozenfindspectests sourcefindspectests util testbothfindspectests machinerymachinery if name main unittest main test find_spec for built in modules common case built in modules cannot be a package built in modules cannot be in a package built in modules cannot be a package built in modules cannot be a package
from test.test_importlib import abc, util

machinery = util.import_importlib('importlib.machinery')

import sys
import unittest


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):

    

    def test_module(self):
        
        with util.uncache(util.BUILTINS.good_name):
            found = self.machinery.BuiltinImporter.find_spec(util.BUILTINS.good_name)
            self.assertTrue(found)
            self.assertEqual(found.origin, 'built-in')

    
    test_package = None

    
    test_module_in_package = None

    
    test_package_in_package = None

    
    test_package_over_module = None

    def test_failure(self):
        name = 'importlib'
        assert name not in sys.builtin_module_names
        spec = self.machinery.BuiltinImporter.find_spec(name)
        self.assertIsNone(spec)


(Frozen_FindSpecTests,
 Source_FindSpecTests
 ) = util.test_both(FindSpecTests, machinery=machinery)


if __name__ == '__main__':
    unittest.main()