]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules unifor...
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Tue, 3 May 2022 07:17:54 +0000 (10:17 +0300)
committerGitHub <noreply@github.com>
Tue, 3 May 2022 07:17:54 +0000 (10:17 +0300)
Lib/test/test_asynchat.py
Lib/test/test_asyncore.py
Lib/test/test_ftplib.py
Lib/test/test_imp.py
Lib/test/test_logging.py
Lib/test/test_poplib.py
Lib/test/test_smtpd.py
Lib/test/test_smtplib.py
Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst [new file with mode: 0644]

index d28d67732e7886f31cf50ff9461d4984b2a4c4c8..9d08bd02968fd60bd6e27ede6a6c45a48e9451b4 100644 (file)
@@ -3,6 +3,7 @@
 from test import support
 from test.support import socket_helper
 from test.support import threading_helper
+from test.support import warnings_helper
 
 import errno
 import socket
@@ -12,11 +13,9 @@ import time
 import unittest
 import unittest.mock
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asynchat
-    import asyncore
+
+asynchat = warnings_helper.import_deprecated('asynchat')
+asyncore = warnings_helper.import_deprecated('asyncore')
 
 support.requires_working_socket(module=True)
 
index e3f31bd06d0c3aa335798a80a80646b19098502e..98ccd3a9304debf322a5129b8fc131054958989d 100644 (file)
@@ -20,10 +20,7 @@ if support.PGO:
 
 support.requires_working_socket(module=True)
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asyncore
+asyncore = warnings_helper.import_deprecated('asyncore')
 
 
 HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')
index 2794fccfe7c72d10a32768128c7e50b03953c54d..082a90d46baedcf9c204595581b435196426fb2e 100644 (file)
@@ -23,11 +23,10 @@ from test.support import socket_helper
 from test.support import warnings_helper
 from test.support.socket_helper import HOST, HOSTv6
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asyncore
-    import asynchat
+
+asynchat = warnings_helper.import_deprecated('asynchat')
+asyncore = warnings_helper.import_deprecated('asyncore')
+
 
 support.requires_working_socket(module=True)
 
index 35e9a2a186552f7ad66266dac77921802f21ec30..d44dc6b49f2935bbb0392e9df3f2bf082fc7dbdf 100644 (file)
@@ -8,11 +8,10 @@ from test import support
 from test.support import import_helper
 from test.support import os_helper
 from test.support import script_helper
+from test.support import warnings_helper
 import unittest
 import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import imp
+imp = warnings_helper.import_deprecated('imp')
 import _imp
 
 
index 7555f05d1d0cf9a845d46ede8a0bb36062f90011..5d4ddedd059fcc50d47ce64bd86aca6ec4c9c671 100644 (file)
@@ -60,10 +60,10 @@ from urllib.parse import urlparse, parse_qs
 from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
                           ThreadingTCPServer, StreamRequestHandler)
 
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asyncore
-    import smtpd
+
+asyncore = warnings_helper.import_deprecated('asyncore')
+smtpd = warnings_helper.import_deprecated('smtpd')
+
 
 try:
     import win32evtlog, win32evtlogutil, pywintypes
index 57ccc541b81fe1babe27af41366c4f078283519b..5ad9202433dcfb61d5b479cb69bb254771f63c1d 100644 (file)
@@ -15,12 +15,12 @@ from test import support as test_support
 from test.support import hashlib_helper
 from test.support import socket_helper
 from test.support import threading_helper
+from test.support import warnings_helper
+
+
+asynchat = warnings_helper.import_deprecated('asynchat')
+asyncore = warnings_helper.import_deprecated('asyncore')
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asynchat
-    import asyncore
 
 test_support.requires_working_socket(module=True)
 
index d2e150d535ff6cb9d2921eecb8096773ba4fda6c..57eb98ebc1d1efffa470639f00ba768f756b40d5 100644 (file)
@@ -6,11 +6,9 @@ from test.support import warnings_helper
 import socket
 import io
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import smtpd
-    import asyncore
+
+smtpd = warnings_helper.import_deprecated('smtpd')
+asyncore = warnings_helper.import_deprecated('asyncore')
 
 
 class DummyServer(smtpd.SMTPServer):
index e798645a5ca66923f399cba9a03d24d31ad06566..a4074c02f1926f867e5f136ed946c21e46787753 100644 (file)
@@ -21,13 +21,13 @@ from test import support, mock_socket
 from test.support import hashlib_helper
 from test.support import socket_helper
 from test.support import threading_helper
+from test.support import warnings_helper
 from unittest.mock import Mock
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asyncore
-    import smtpd
+
+asyncore = warnings_helper.import_deprecated('asyncore')
+smtpd = warnings_helper.import_deprecated('smtpd')
+
 
 support.requires_working_socket(module=True)
 
index 543d34a5469333659088d6a8deadfa21f6cf6242..0eb8d18b3561ee1c919edd819ffddcff2f50273c 100644 (file)
@@ -12,7 +12,6 @@ from test.support import warnings_helper
 import socket
 import select
 import time
-import datetime
 import enum
 import gc
 import os
@@ -30,10 +29,9 @@ try:
 except ImportError:
     ctypes = None
 
-import warnings
-with warnings.catch_warnings():
-    warnings.simplefilter('ignore', DeprecationWarning)
-    import asyncore
+
+asyncore = warnings_helper.import_deprecated('asyncore')
+
 
 ssl = import_helper.import_module("ssl")
 import _ssl
diff --git a/Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst b/Misc/NEWS.d/next/Tests/2022-05-02-20-57-04.gh-issue-92169.Xi4NGV.rst
new file mode 100644 (file)
index 0000000..3809ed4
--- /dev/null
@@ -0,0 +1,2 @@
+Use ``warnings_helper.import_deprecated()`` to import deprecated modules
+uniformly in tests. Patch by Hugo van Kemenade.