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
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)
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')
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)
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
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
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)
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):
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)
import socket
import select
import time
-import datetime
import enum
import gc
import os
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
--- /dev/null
+Use ``warnings_helper.import_deprecated()`` to import deprecated modules
+uniformly in tests. Patch by Hugo van Kemenade.