Kaydet (Commit) 9e7990ae authored tarafından Berker Peksag's avatar Berker Peksag

Issue #24210: Silence more PendingDeprecationWarning warnings in tests.

üst b744f3a4
...@@ -236,6 +236,13 @@ class PlatformTest(unittest.TestCase): ...@@ -236,6 +236,13 @@ class PlatformTest(unittest.TestCase):
self.assertEqual(sts, 0) self.assertEqual(sts, 0)
def test_dist(self): def test_dist(self):
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore',
'dist\(\) and linux_distribution\(\) '
'functions are deprecated .*',
PendingDeprecationWarning,
)
res = platform.dist() res = platform.dist()
def test_libc_ver(self): def test_libc_ver(self):
...@@ -305,6 +312,13 @@ class PlatformTest(unittest.TestCase): ...@@ -305,6 +312,13 @@ 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):
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore',
'dist\(\) and linux_distribution\(\) '
'functions are deprecated .*',
PendingDeprecationWarning,
)
distname, version, distid = platform.linux_distribution() distname, version, distid = platform.linux_distribution()
self.assertEqual(distname, 'Fedora') self.assertEqual(distname, 'Fedora')
......
...@@ -3294,11 +3294,19 @@ else: ...@@ -3294,11 +3294,19 @@ 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,
} }
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore',
'dist\(\) and linux_distribution\(\) '
'functions are deprecated .*',
PendingDeprecationWarning,
)
for name, func in plats.items(): for name, func in plats.items():
plat = func() plat = func()
if plat and plat[0]: if plat and plat[0]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment