Issue #24210: Silence more PendingDeprecationWarning warnings in tests.

This commit is contained in:
Berker Peksag 2015-05-16 23:21:26 +03:00
parent b744f3a45e
commit 9e7990ae21
2 changed files with 31 additions and 9 deletions

View file

@ -236,6 +236,13 @@ class PlatformTest(unittest.TestCase):
self.assertEqual(sts, 0)
def test_dist(self):
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore',
'dist\(\) and linux_distribution\(\) '
'functions are deprecated .*',
PendingDeprecationWarning,
)
res = platform.dist()
def test_libc_ver(self):
@ -305,6 +312,13 @@ class PlatformTest(unittest.TestCase):
f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')
with mock.patch('platform._UNIXCONFDIR', tempdir):
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')

View file

@ -3294,11 +3294,19 @@ else:
def test_main(verbose=False):
if support.verbose:
import warnings
plats = {
'Linux': platform.linux_distribution,
'Mac': platform.mac_ver,
'Windows': platform.win32_ver,
}
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]: