mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-09-11 16:58:42 -06:00
Removed the Requirement to Install Python and NodeJS (Now Bundled with Borealis)
This commit is contained in:
5
Dependencies/Python/Lib/test/test_importlib/builtin/__init__.py
vendored
Normal file
5
Dependencies/Python/Lib/test/test_importlib/builtin/__init__.py
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import os
|
||||
from test.support import load_package_tests
|
||||
|
||||
def load_tests(*args):
|
||||
return load_package_tests(os.path.dirname(__file__), *args)
|
4
Dependencies/Python/Lib/test/test_importlib/builtin/__main__.py
vendored
Normal file
4
Dependencies/Python/Lib/test/test_importlib/builtin/__main__.py
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
from . import load_tests
|
||||
import unittest
|
||||
|
||||
unittest.main()
|
46
Dependencies/Python/Lib/test/test_importlib/builtin/test_finder.py
vendored
Normal file
46
Dependencies/Python/Lib/test/test_importlib/builtin/test_finder.py
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
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):
|
||||
|
||||
"""Test find_spec() for built-in modules."""
|
||||
|
||||
def test_module(self):
|
||||
# Common case.
|
||||
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')
|
||||
|
||||
# Built-in modules cannot be a package.
|
||||
test_package = None
|
||||
|
||||
# Built-in modules cannot be in a package.
|
||||
test_module_in_package = None
|
||||
|
||||
# Built-in modules cannot be a package.
|
||||
test_package_in_package = None
|
||||
|
||||
# Built-in modules cannot be a package.
|
||||
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()
|
110
Dependencies/Python/Lib/test/test_importlib/builtin/test_loader.py
vendored
Normal file
110
Dependencies/Python/Lib/test/test_importlib/builtin/test_loader.py
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
from test.test_importlib import abc, util
|
||||
|
||||
machinery = util.import_importlib('importlib.machinery')
|
||||
|
||||
import sys
|
||||
import types
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
|
||||
class LoaderTests(abc.LoaderTests):
|
||||
|
||||
"""Test load_module() for built-in modules."""
|
||||
|
||||
def setUp(self):
|
||||
self.verification = {'__name__': 'errno', '__package__': '',
|
||||
'__loader__': self.machinery.BuiltinImporter}
|
||||
|
||||
def verify(self, module):
|
||||
"""Verify that the module matches against what it should have."""
|
||||
self.assertIsInstance(module, types.ModuleType)
|
||||
for attr, value in self.verification.items():
|
||||
self.assertEqual(getattr(module, attr), value)
|
||||
self.assertIn(module.__name__, sys.modules)
|
||||
|
||||
def load_module(self, name):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
return self.machinery.BuiltinImporter.load_module(name)
|
||||
|
||||
def test_module(self):
|
||||
# Common case.
|
||||
with util.uncache(util.BUILTINS.good_name):
|
||||
module = self.load_module(util.BUILTINS.good_name)
|
||||
self.verify(module)
|
||||
|
||||
# Built-in modules cannot be a package.
|
||||
test_package = test_lacking_parent = None
|
||||
|
||||
# No way to force an import failure.
|
||||
test_state_after_failure = None
|
||||
|
||||
def test_module_reuse(self):
|
||||
# Test that the same module is used in a reload.
|
||||
with util.uncache(util.BUILTINS.good_name):
|
||||
module1 = self.load_module(util.BUILTINS.good_name)
|
||||
module2 = self.load_module(util.BUILTINS.good_name)
|
||||
self.assertIs(module1, module2)
|
||||
|
||||
def test_unloadable(self):
|
||||
name = 'dssdsdfff'
|
||||
assert name not in sys.builtin_module_names
|
||||
with self.assertRaises(ImportError) as cm:
|
||||
self.load_module(name)
|
||||
self.assertEqual(cm.exception.name, name)
|
||||
|
||||
def test_already_imported(self):
|
||||
# Using the name of a module already imported but not a built-in should
|
||||
# still fail.
|
||||
module_name = 'builtin_reload_test'
|
||||
assert module_name not in sys.builtin_module_names
|
||||
with util.uncache(module_name):
|
||||
module = types.ModuleType(module_name)
|
||||
sys.modules[module_name] = module
|
||||
with self.assertRaises(ImportError) as cm:
|
||||
self.load_module(module_name)
|
||||
self.assertEqual(cm.exception.name, module_name)
|
||||
|
||||
|
||||
(Frozen_LoaderTests,
|
||||
Source_LoaderTests
|
||||
) = util.test_both(LoaderTests, machinery=machinery)
|
||||
|
||||
|
||||
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
|
||||
class InspectLoaderTests:
|
||||
|
||||
"""Tests for InspectLoader methods for BuiltinImporter."""
|
||||
|
||||
def test_get_code(self):
|
||||
# There is no code object.
|
||||
result = self.machinery.BuiltinImporter.get_code(util.BUILTINS.good_name)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_get_source(self):
|
||||
# There is no source.
|
||||
result = self.machinery.BuiltinImporter.get_source(util.BUILTINS.good_name)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_is_package(self):
|
||||
# Cannot be a package.
|
||||
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
|
||||
self.assertFalse(result)
|
||||
|
||||
@unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in')
|
||||
def test_not_builtin(self):
|
||||
# Modules not built-in should raise ImportError.
|
||||
for meth_name in ('get_code', 'get_source', 'is_package'):
|
||||
method = getattr(self.machinery.BuiltinImporter, meth_name)
|
||||
with self.assertRaises(ImportError) as cm:
|
||||
method(util.BUILTINS.bad_name)
|
||||
|
||||
|
||||
(Frozen_InspectLoaderTests,
|
||||
Source_InspectLoaderTests
|
||||
) = util.test_both(InspectLoaderTests, machinery=machinery)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user