summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_platform.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-10 11:59:59 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-10 11:59:59 (GMT)
commit3a38a6db432e518f384d546646c678425a80f001 (patch)
tree624c9ad303f43ccb378d3d45cc775a4332b5c321 /Lib/test/test_platform.py
parent46591664fa6fc75739fad055ca5bd306845c7017 (diff)
downloadcpython-3a38a6db432e518f384d546646c678425a80f001.zip
cpython-3a38a6db432e518f384d546646c678425a80f001.tar.gz
cpython-3a38a6db432e518f384d546646c678425a80f001.tar.bz2
test_platform: ignore DeprecationWarning on popen() test
Diffstat (limited to 'Lib/test/test_platform.py')
-rw-r--r--Lib/test/test_platform.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index b59f6e6..93f86d9 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -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 @@ class PlatformTest(unittest.TestCase):
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 @@ class PlatformTest(unittest.TestCase):
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():