mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170)
This commit is contained in:
		
							parent
							
								
									c1767fce52
								
							
						
					
					
						commit
						9b027d4cea
					
				
					 10 changed files with 33 additions and 41 deletions
				
			
		| 
						 | 
					@ -3,6 +3,7 @@
 | 
				
			||||||
from test import support
 | 
					from test import support
 | 
				
			||||||
from test.support import socket_helper
 | 
					from test.support import socket_helper
 | 
				
			||||||
from test.support import threading_helper
 | 
					from test.support import threading_helper
 | 
				
			||||||
 | 
					from test.support import warnings_helper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import errno
 | 
					import errno
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
| 
						 | 
					@ -12,11 +13,9 @@
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
import unittest.mock
 | 
					import unittest.mock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import warnings
 | 
					
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					asynchat = warnings_helper.import_deprecated('asynchat')
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
    import asynchat
 | 
					 | 
				
			||||||
    import asyncore
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
support.requires_working_socket(module=True)
 | 
					support.requires_working_socket(module=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,10 +20,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
support.requires_working_socket(module=True)
 | 
					support.requires_working_socket(module=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import warnings
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					 | 
				
			||||||
    import asyncore
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')
 | 
					HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,11 +23,10 @@
 | 
				
			||||||
from test.support import warnings_helper
 | 
					from test.support import warnings_helper
 | 
				
			||||||
from test.support.socket_helper import HOST, HOSTv6
 | 
					from test.support.socket_helper import HOST, HOSTv6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import warnings
 | 
					
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					asynchat = warnings_helper.import_deprecated('asynchat')
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
    import asyncore
 | 
					
 | 
				
			||||||
    import asynchat
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
support.requires_working_socket(module=True)
 | 
					support.requires_working_socket(module=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,11 +8,10 @@
 | 
				
			||||||
from test.support import import_helper
 | 
					from test.support import import_helper
 | 
				
			||||||
from test.support import os_helper
 | 
					from test.support import os_helper
 | 
				
			||||||
from test.support import script_helper
 | 
					from test.support import script_helper
 | 
				
			||||||
 | 
					from test.support import warnings_helper
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
import warnings
 | 
					import warnings
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					imp = warnings_helper.import_deprecated('imp')
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					 | 
				
			||||||
    import imp
 | 
					 | 
				
			||||||
import _imp
 | 
					import _imp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,10 +60,10 @@
 | 
				
			||||||
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
 | 
					from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
 | 
				
			||||||
                          ThreadingTCPServer, StreamRequestHandler)
 | 
					                          ThreadingTCPServer, StreamRequestHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
    import asyncore
 | 
					smtpd = warnings_helper.import_deprecated('smtpd')
 | 
				
			||||||
    import smtpd
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    import win32evtlog, win32evtlogutil, pywintypes
 | 
					    import win32evtlog, win32evtlogutil, pywintypes
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,12 +15,12 @@
 | 
				
			||||||
from test.support import hashlib_helper
 | 
					from test.support import hashlib_helper
 | 
				
			||||||
from test.support import socket_helper
 | 
					from test.support import socket_helper
 | 
				
			||||||
from test.support import threading_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)
 | 
					test_support.requires_working_socket(module=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,11 +6,9 @@
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
import io
 | 
					import io
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import warnings
 | 
					
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					smtpd = warnings_helper.import_deprecated('smtpd')
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
    import smtpd
 | 
					 | 
				
			||||||
    import asyncore
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DummyServer(smtpd.SMTPServer):
 | 
					class DummyServer(smtpd.SMTPServer):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,13 +21,13 @@
 | 
				
			||||||
from test.support import hashlib_helper
 | 
					from test.support import hashlib_helper
 | 
				
			||||||
from test.support import socket_helper
 | 
					from test.support import socket_helper
 | 
				
			||||||
from test.support import threading_helper
 | 
					from test.support import threading_helper
 | 
				
			||||||
 | 
					from test.support import warnings_helper
 | 
				
			||||||
from unittest.mock import Mock
 | 
					from unittest.mock import Mock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import warnings
 | 
					
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					smtpd = warnings_helper.import_deprecated('smtpd')
 | 
				
			||||||
    import asyncore
 | 
					
 | 
				
			||||||
    import smtpd
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
support.requires_working_socket(module=True)
 | 
					support.requires_working_socket(module=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,6 @@
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
import select
 | 
					import select
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
import datetime
 | 
					 | 
				
			||||||
import enum
 | 
					import enum
 | 
				
			||||||
import gc
 | 
					import gc
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
| 
						 | 
					@ -30,10 +29,9 @@
 | 
				
			||||||
except ImportError:
 | 
					except ImportError:
 | 
				
			||||||
    ctypes = None
 | 
					    ctypes = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import warnings
 | 
					
 | 
				
			||||||
with warnings.catch_warnings():
 | 
					asyncore = warnings_helper.import_deprecated('asyncore')
 | 
				
			||||||
    warnings.simplefilter('ignore', DeprecationWarning)
 | 
					
 | 
				
			||||||
    import asyncore
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
ssl = import_helper.import_module("ssl")
 | 
					ssl = import_helper.import_module("ssl")
 | 
				
			||||||
import _ssl
 | 
					import _ssl
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					Use ``warnings_helper.import_deprecated()`` to import deprecated modules
 | 
				
			||||||
 | 
					uniformly in tests. Patch by Hugo van Kemenade.
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue