Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-92169: Use warnings_helper.import_deprecated() in tests #92170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Lib/test/test_asynchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,11 +13,9 @@
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)

Expand Down
5 changes: 1 addition & 4 deletions Lib/test/test_asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

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')
Expand Down
9 changes: 4 additions & 5 deletions Lib/test/test_ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
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)

Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
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


Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
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
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_poplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
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)

Expand Down
8 changes: 3 additions & 5 deletions Lib/test/test_smtpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
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):
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
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)

Expand Down
8 changes: 3 additions & 5 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import socket
import select
import time
import datetime
import enum
import gc
import os
Expand All @@ -30,10 +29,9 @@
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use ``warnings_helper.import_deprecated()`` to import deprecated modules
uniformly in tests. Patch by Hugo van Kemenade.