[Python-checkins] cpython: Issue #24210: Silence more PendingDeprecationWarning warnings in tests.
berker.peksag
python-checkins at python.org
Sat May 16 22:21:31 CEST 2015
https://hg.python.org/cpython/rev/e73182301a61
changeset: 96104:e73182301a61
user: Berker Peksag <berker.peksag at gmail.com>
date: Sat May 16 23:21:26 2015 +0300
summary:
Issue #24210: Silence more PendingDeprecationWarning warnings in tests.
files:
Lib/test/test_platform.py | 18 ++++++++++++++++--
Lib/test/test_ssl.py | 22 +++++++++++++++-------
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -236,7 +236,14 @@
self.assertEqual(sts, 0)
def test_dist(self):
- res = platform.dist()
+ with warnings.catch_warnings():
+ warnings.filterwarnings(
+ 'ignore',
+ 'dist\(\) and linux_distribution\(\) '
+ 'functions are deprecated .*',
+ PendingDeprecationWarning,
+ )
+ res = platform.dist()
def test_libc_ver(self):
import os
@@ -305,7 +312,14 @@
f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')
with mock.patch('platform._UNIXCONFDIR', tempdir):
- distname, version, distid = platform.linux_distribution()
+ with warnings.catch_warnings():
+ warnings.filterwarnings(
+ 'ignore',
+ 'dist\(\) and linux_distribution\(\) '
+ 'functions are deprecated .*',
+ PendingDeprecationWarning,
+ )
+ distname, version, distid = platform.linux_distribution()
self.assertEqual(distname, 'Fedora')
self.assertEqual(version, '19')
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -3294,18 +3294,26 @@
def test_main(verbose=False):
if support.verbose:
+ import warnings
plats = {
'Linux': platform.linux_distribution,
'Mac': platform.mac_ver,
'Windows': platform.win32_ver,
}
- for name, func in plats.items():
- plat = func()
- if plat and plat[0]:
- plat = '%s %r' % (name, plat)
- break
- else:
- plat = repr(platform.platform())
+ with warnings.catch_warnings():
+ warnings.filterwarnings(
+ 'ignore',
+ 'dist\(\) and linux_distribution\(\) '
+ 'functions are deprecated .*',
+ PendingDeprecationWarning,
+ )
+ for name, func in plats.items():
+ plat = func()
+ if plat and plat[0]:
+ plat = '%s %r' % (name, plat)
+ break
+ else:
+ plat = repr(platform.platform())
print("test_ssl: testing with %r %r" %
(ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
print(" under %s" % plat)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list