Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert changes made by Black
  • Loading branch information
brettcannon committed Apr 4, 2023
commit 5d5b934975bd6cc767d113b819252a36068cff0e
34 changes: 16 additions & 18 deletions Lib/test/test_importlib/builtin/test_finder.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from test.test_importlib import abc, util

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

import sys
import unittest
import warnings


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

"""Test find_spec() for built-in modules."""
Expand All @@ -17,7 +17,7 @@ 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")
self.assertEqual(found.origin, 'built-in')

# Built-in modules cannot be a package.
test_package = None
Expand All @@ -32,18 +32,18 @@ def test_module(self):
test_package_over_module = None

def test_failure(self):
name = "importlib"
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
)
(Frozen_FindSpecTests,
Source_FindSpecTests
) = util.test_both(FindSpecTests, machinery=machinery)


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

"""Test find_module() for built-in modules."""
Expand All @@ -53,11 +53,9 @@ def test_module(self):
with util.uncache(util.BUILTINS.good_name):
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
found = self.machinery.BuiltinImporter.find_module(
util.BUILTINS.good_name
)
found = self.machinery.BuiltinImporter.find_module(util.BUILTINS.good_name)
self.assertTrue(found)
self.assertTrue(hasattr(found, "load_module"))
self.assertTrue(hasattr(found, 'load_module'))

# Built-in modules cannot be a package.
test_package = test_package_in_package = test_package_over_module = None
Expand All @@ -66,17 +64,17 @@ def test_module(self):
test_module_in_package = None

def test_failure(self):
assert "importlib" not in sys.builtin_module_names
assert 'importlib' not in sys.builtin_module_names
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
loader = self.machinery.BuiltinImporter.find_module("importlib")
loader = self.machinery.BuiltinImporter.find_module('importlib')
self.assertIsNone(loader)


(Frozen_FinderTests, Source_FinderTests) = util.test_both(
FinderTests, machinery=machinery
)
(Frozen_FinderTests,
Source_FinderTests
) = util.test_both(FinderTests, machinery=machinery)


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