Skip to content

Commit 8bec9fb

Browse files
bpo-44498: suppress DeprecationWarnings for asynchat, asyncore and smtpd in tests (GH-26905) (GH-26907)
(cherry picked from commit 22e7effad571f8e524d2f71ff55bbf2a25306753) Co-authored-by: Irit Katriel <[email protected]>
1 parent a80a38e commit 8bec9fb

9 files changed

+51
-16
lines changed

Lib/test/test_asynchat.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from test.support import socket_helper
55
from test.support import threading_helper
66

7-
import asynchat
8-
import asyncore
97
import errno
108
import socket
119
import sys
@@ -14,6 +12,12 @@
1412
import unittest
1513
import unittest.mock
1614

15+
import warnings
16+
with warnings.catch_warnings():
17+
warnings.simplefilter('ignore', DeprecationWarning)
18+
import asynchat
19+
import asyncore
20+
1721
HOST = socket_helper.HOST
1822
SERVER_QUIT = b'QUIT\n'
1923

Lib/test/test_asyncore.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncore
21
import unittest
32
import select
43
import os
@@ -19,6 +18,11 @@
1918
if support.PGO:
2019
raise unittest.SkipTest("test is not helpful for PGO")
2120

21+
import warnings
22+
with warnings.catch_warnings():
23+
warnings.simplefilter('ignore', DeprecationWarning)
24+
import asyncore
25+
2226

2327
HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')
2428

Lib/test/test_ftplib.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# environment
55

66
import ftplib
7-
import asyncore
8-
import asynchat
97
import socket
108
import io
119
import errno
@@ -24,6 +22,13 @@
2422
from test.support import warnings_helper
2523
from test.support.socket_helper import HOST, HOSTv6
2624

25+
import warnings
26+
with warnings.catch_warnings():
27+
warnings.simplefilter('ignore', DeprecationWarning)
28+
import asyncore
29+
import asynchat
30+
31+
2732
TIMEOUT = support.LOOPBACK_TIMEOUT
2833
DEFAULT_ENCODING = 'utf-8'
2934
# the dummy data returned by server over the data channel when

Lib/test/test_logging.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@
5454
import warnings
5555
import weakref
5656

57-
import asyncore
5857
from http.server import HTTPServer, BaseHTTPRequestHandler
59-
import smtpd
6058
from urllib.parse import urlparse, parse_qs
6159
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
6260
ThreadingTCPServer, StreamRequestHandler)
6361

62+
with warnings.catch_warnings():
63+
warnings.simplefilter('ignore', DeprecationWarning)
64+
import asyncore
65+
import smtpd
66+
6467
try:
6568
import win32evtlog, win32evtlogutil, pywintypes
6669
except ImportError:

Lib/test/test_os.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# does add tests for a few functions which have been determined to be more
33
# portable than they had been thought to be.
44

5-
import asynchat
6-
import asyncore
75
import codecs
86
import contextlib
97
import decimal
@@ -39,6 +37,11 @@
3937
from test.support import warnings_helper
4038
from platform import win32_is_iot
4139

40+
with warnings.catch_warnings():
41+
warnings.simplefilter('ignore', DeprecationWarning)
42+
import asynchat
43+
import asyncore
44+
4245
try:
4346
import resource
4447
except ImportError:

Lib/test/test_poplib.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# a real test suite
55

66
import poplib
7-
import asyncore
8-
import asynchat
97
import socket
108
import os
119
import errno
@@ -17,6 +15,12 @@
1715
from test.support import socket_helper
1816
from test.support import threading_helper
1917

18+
import warnings
19+
with warnings.catch_warnings():
20+
warnings.simplefilter('ignore', DeprecationWarning)
21+
import asynchat
22+
import asyncore
23+
2024
HOST = socket_helper.HOST
2125
PORT = 0
2226

Lib/test/test_smtpd.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
from test.support import warnings_helper
66
import socket
77
import io
8-
import smtpd
9-
import asyncore
8+
9+
import warnings
10+
with warnings.catch_warnings():
11+
warnings.simplefilter('ignore', DeprecationWarning)
12+
import smtpd
13+
import asyncore
1014

1115

1216
class DummyServer(smtpd.SMTPServer):

Lib/test/test_smtplib.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncore
21
import base64
32
import email.mime.text
43
from email.message import EmailMessage
@@ -7,7 +6,6 @@
76
import hashlib
87
import hmac
98
import socket
10-
import smtpd
119
import smtplib
1210
import io
1311
import re
@@ -25,6 +23,12 @@
2523
from test.support import threading_helper
2624
from unittest.mock import Mock
2725

26+
import warnings
27+
with warnings.catch_warnings():
28+
warnings.simplefilter('ignore', DeprecationWarning)
29+
import asyncore
30+
import smtpd
31+
2832
HOST = socket_helper.HOST
2933

3034
if sys.platform == 'darwin':

Lib/test/test_ssl.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import urllib.request
2222
import threading
2323
import traceback
24-
import asyncore
2524
import weakref
2625
import platform
2726
import sysconfig
@@ -31,6 +30,11 @@
3130
except ImportError:
3231
ctypes = None
3332

33+
import warnings
34+
with warnings.catch_warnings():
35+
warnings.simplefilter('ignore', DeprecationWarning)
36+
import asyncore
37+
3438
ssl = import_helper.import_module("ssl")
3539
import _ssl
3640

0 commit comments

Comments
 (0)