mirror of
https://github.com/python/cpython.git
synced 2025-10-27 11:44:39 +00:00
gh-121604: fix warnings in test_importlib.test_abc and test_importlib.test_windows (GH-128904)
This commit is contained in:
parent
211f41316b
commit
27494dd9ad
2 changed files with 48 additions and 7 deletions
|
|
@ -91,23 +91,46 @@ class WindowsRegistryFinderTests:
|
|||
test_module = "spamham{}".format(os.getpid())
|
||||
|
||||
def test_find_spec_missing(self):
|
||||
spec = self.machinery.WindowsRegistryFinder.find_spec('spam')
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
|
||||
r"use site configuration instead\. Future versions of Python may "
|
||||
r"not enable this finder by default\."
|
||||
):
|
||||
spec = self.machinery.WindowsRegistryFinder.find_spec('spam')
|
||||
self.assertIsNone(spec)
|
||||
|
||||
def test_module_found(self):
|
||||
with setup_module(self.machinery, self.test_module):
|
||||
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
|
||||
r"use site configuration instead\. Future versions of Python may "
|
||||
r"not enable this finder by default\."
|
||||
):
|
||||
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
|
||||
self.assertIsNotNone(spec)
|
||||
|
||||
def test_module_not_found(self):
|
||||
with setup_module(self.machinery, self.test_module, path="."):
|
||||
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
|
||||
r"use site configuration instead\. Future versions of Python may "
|
||||
r"not enable this finder by default\."
|
||||
):
|
||||
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
|
||||
self.assertIsNone(spec)
|
||||
|
||||
def test_raises_deprecation_warning(self):
|
||||
# WindowsRegistryFinder is not meant to be instantiated, so the
|
||||
# deprecation warning is raised in the 'find_spec' method instead.
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
|
||||
r"use site configuration instead\. Future versions of Python may "
|
||||
r"not enable this finder by default\."
|
||||
):
|
||||
self.machinery.WindowsRegistryFinder.find_spec('spam')
|
||||
|
||||
(Frozen_WindowsRegistryFinderTests,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue