Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_platform.py @ 70755:5a745404facf
test_platform: ignore DeprecationWarning on popen() test
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Fri, 10 Jun 2011 13:59:59 +0200 |
| parents | 0e7e3b1621da |
| children | 0025ce38fbd0 |
line wrap: on
line diff
--- a/Lib/test/test_platform.py Fri Jun 10 13:53:32 2011 +0200 +++ b/Lib/test/test_platform.py Fri Jun 10 13:59:59 2011 +0200 @@ -1,8 +1,9 @@ -import sys import os -import unittest import platform import subprocess +import sys +import unittest +import warnings from test import support @@ -250,10 +251,12 @@ command = '"{}" -c "print(\'Hello\')"'.format(sys.executable) else: command = "'{}' -c 'print(\"Hello\")'".format(sys.executable) - with platform.popen(command) as stdout: - hello = stdout.read().strip() - stdout.close() - self.assertEqual(hello, "Hello") + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + with platform.popen(command) as stdout: + hello = stdout.read().strip() + stdout.close() + self.assertEqual(hello, "Hello") data = 'plop' if mswindows: @@ -261,15 +264,17 @@ else: command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'" command = command.format(sys.executable) - with platform.popen(command, 'w') as stdin: - stdout = stdin.write(data) - ret = stdin.close() - self.assertIsNotNone(ret) - if os.name == 'nt': - returncode = ret - else: - returncode = ret >> 8 - self.assertEqual(returncode, len(data)) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + with platform.popen(command, 'w') as stdin: + stdout = stdin.write(data) + ret = stdin.close() + self.assertIsNotNone(ret) + if os.name == 'nt': + returncode = ret + else: + returncode = ret >> 8 + self.assertEqual(returncode, len(data)) def test_main():
