mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Issue #24210: Silence more PendingDeprecationWarning warnings in tests.
This commit is contained in:
parent
b744f3a45e
commit
9e7990ae21
2 changed files with 31 additions and 9 deletions
|
@ -236,7 +236,14 @@ class PlatformTest(unittest.TestCase):
|
||||||
self.assertEqual(sts, 0)
|
self.assertEqual(sts, 0)
|
||||||
|
|
||||||
def test_dist(self):
|
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):
|
def test_libc_ver(self):
|
||||||
import os
|
import os
|
||||||
|
@ -305,7 +312,14 @@ class PlatformTest(unittest.TestCase):
|
||||||
f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')
|
f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')
|
||||||
|
|
||||||
with mock.patch('platform._UNIXCONFDIR', tempdir):
|
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(distname, 'Fedora')
|
||||||
self.assertEqual(version, '19')
|
self.assertEqual(version, '19')
|
||||||
|
|
|
@ -3294,18 +3294,26 @@ else:
|
||||||
|
|
||||||
def test_main(verbose=False):
|
def test_main(verbose=False):
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
|
import warnings
|
||||||
plats = {
|
plats = {
|
||||||
'Linux': platform.linux_distribution,
|
'Linux': platform.linux_distribution,
|
||||||
'Mac': platform.mac_ver,
|
'Mac': platform.mac_ver,
|
||||||
'Windows': platform.win32_ver,
|
'Windows': platform.win32_ver,
|
||||||
}
|
}
|
||||||
for name, func in plats.items():
|
with warnings.catch_warnings():
|
||||||
plat = func()
|
warnings.filterwarnings(
|
||||||
if plat and plat[0]:
|
'ignore',
|
||||||
plat = '%s %r' % (name, plat)
|
'dist\(\) and linux_distribution\(\) '
|
||||||
break
|
'functions are deprecated .*',
|
||||||
else:
|
PendingDeprecationWarning,
|
||||||
plat = repr(platform.platform())
|
)
|
||||||
|
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" %
|
print("test_ssl: testing with %r %r" %
|
||||||
(ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
|
(ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
|
||||||
print(" under %s" % plat)
|
print(" under %s" % plat)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue