Skip to content

Commit

Permalink
bpo-44498: suppress DeprecationWarnings for asynchat, asyncore and sm…
Browse files Browse the repository at this point in the history
…tpd in tests (pythonGH-26905) (pythonGH-26907)

(cherry picked from commit 22e7eff)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
  • Loading branch information
miss-islington and iritkatriel authored Jun 24, 2021
1 parent a80a38e commit 8bec9fb
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 16 deletions.
8 changes: 6 additions & 2 deletions Lib/test/test_asynchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from test.support import socket_helper
from test.support import threading_helper

import asynchat
import asyncore
import errno
import socket
import sys
Expand All @@ -14,6 +12,12 @@
import unittest
import unittest.mock

import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import asynchat
import asyncore

HOST = socket_helper.HOST
SERVER_QUIT = b'QUIT\n'

Expand Down
6 changes: 5 additions & 1 deletion Lib/test/test_asyncore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncore
import unittest
import select
import os
Expand All @@ -19,6 +18,11 @@
if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")

import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import asyncore


HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')

Expand Down
9 changes: 7 additions & 2 deletions Lib/test/test_ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# environment

import ftplib
import asyncore
import asynchat
import socket
import io
import errno
Expand All @@ -24,6 +22,13 @@
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


TIMEOUT = support.LOOPBACK_TIMEOUT
DEFAULT_ENCODING = 'utf-8'
# the dummy data returned by server over the data channel when
Expand Down
7 changes: 5 additions & 2 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@
import warnings
import weakref

import asyncore
from http.server import HTTPServer, BaseHTTPRequestHandler
import smtpd
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

try:
import win32evtlog, win32evtlogutil, pywintypes
except ImportError:
Expand Down
7 changes: 5 additions & 2 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# does add tests for a few functions which have been determined to be more
# portable than they had been thought to be.

import asynchat
import asyncore
import codecs
import contextlib
import decimal
Expand Down Expand Up @@ -39,6 +37,11 @@
from test.support import warnings_helper
from platform import win32_is_iot

with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import asynchat
import asyncore

try:
import resource
except ImportError:
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_poplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# a real test suite

import poplib
import asyncore
import asynchat
import socket
import os
import errno
Expand All @@ -17,6 +15,12 @@
from test.support import socket_helper
from test.support import threading_helper

import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import asynchat
import asyncore

HOST = socket_helper.HOST
PORT = 0

Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_smtpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
from test.support import warnings_helper
import socket
import io
import smtpd
import asyncore

import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import smtpd
import asyncore


class DummyServer(smtpd.SMTPServer):
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_smtplib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncore
import base64
import email.mime.text
from email.message import EmailMessage
Expand All @@ -7,7 +6,6 @@
import hashlib
import hmac
import socket
import smtpd
import smtplib
import io
import re
Expand All @@ -25,6 +23,12 @@
from test.support import threading_helper
from unittest.mock import Mock

import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import asyncore
import smtpd

HOST = socket_helper.HOST

if sys.platform == 'darwin':
Expand Down
6 changes: 5 additions & 1 deletion Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import urllib.request
import threading
import traceback
import asyncore
import weakref
import platform
import sysconfig
Expand All @@ -31,6 +30,11 @@
except ImportError:
ctypes = None

import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import asyncore

ssl = import_helper.import_module("ssl")
import _ssl

Expand Down

0 comments on commit 8bec9fb

Please sign in to comment.