[Python-checkins] bpo-43864: Silence deprecation warning in test_importlib.test_module_found and test_importlib.test_module_not_found (GH-25656)

zooba webhook-mailer at python.org
Tue Apr 27 11:56:17 EDT 2021


https://github.com/python/cpython/commit/e3bf179642a3445fb079454f382b93d0177f5012
commit: e3bf179642a3445fb079454f382b93d0177f5012
branch: master
author: Shreyan Avigyan <shreyan.avigyan at gmail.com>
committer: zooba <steve.dower at microsoft.com>
date: 2021-04-27T16:56:08+01:00
summary:

bpo-43864: Silence deprecation warning in test_importlib.test_module_found and test_importlib.test_module_not_found (GH-25656)

files:
M Lib/test/test_importlib/test_windows.py

diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py
index b24383618c81f..6f09c5a7a5a46 100644
--- a/Lib/test/test_importlib/test_windows.py
+++ b/Lib/test/test_importlib/test_windows.py
@@ -92,14 +92,18 @@ def test_find_module_missing(self):
 
     def test_module_found(self):
         with setup_module(self.machinery, self.test_module):
-            loader = self.machinery.WindowsRegistryFinder.find_module(self.test_module)
+            with warnings.catch_warnings():
+                warnings.simplefilter("ignore", DeprecationWarning)
+                loader = self.machinery.WindowsRegistryFinder.find_module(self.test_module)
             spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
             self.assertIsNot(loader, None)
             self.assertIsNot(spec, None)
 
     def test_module_not_found(self):
         with setup_module(self.machinery, self.test_module, path="."):
-            loader = self.machinery.WindowsRegistryFinder.find_module(self.test_module)
+            with warnings.catch_warnings():
+                warnings.simplefilter("ignore", DeprecationWarning)
+                loader = self.machinery.WindowsRegistryFinder.find_module(self.test_module)
             spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
             self.assertIsNone(loader)
             self.assertIsNone(spec)



More information about the Python-checkins mailing list