summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/test_windows.py
diff options
context:
space:
mode:
authorThomas Grainger <tagrain@gmail.com>2025-01-16 21:29:16 (GMT)
committerGitHub <noreply@github.com>2025-01-16 21:29:16 (GMT)
commit27494dd9ad6032c29e273cd7f45c204c00d6512c (patch)
tree8e4b197649563a09f7b744c6604f1f2b40105121 /Lib/test/test_importlib/test_windows.py
parent211f41316b7f205d18eb65c1ececd7f7fb30b02d (diff)
downloadcpython-27494dd9ad6032c29e273cd7f45c204c00d6512c.zip
cpython-27494dd9ad6032c29e273cd7f45c204c00d6512c.tar.gz
cpython-27494dd9ad6032c29e273cd7f45c204c00d6512c.tar.bz2
gh-121604: fix warnings in test_importlib.test_abc and test_importlib.test_windows (GH-128904)
Diffstat (limited to 'Lib/test/test_importlib/test_windows.py')
-rw-r--r--Lib/test/test_importlib/test_windows.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py
index f32680b..bef4fb4 100644
--- a/Lib/test/test_importlib/test_windows.py
+++ b/Lib/test/test_importlib/test_windows.py
@@ -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,