summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_platform.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-29 08:58:20 (GMT)
committerGitHub <noreply@github.com>2018-11-29 08:58:20 (GMT)
commit73104fa1e6a791f7d66c0091ed91f6c396ca0fb2 (patch)
tree460498e3e8f71eedf8f751ec72fe2662f2af5983 /Lib/test/test_platform.py
parent7cc1fa40b76de34a0fe86162667c87ce7a18f33d (diff)
downloadcpython-73104fa1e6a791f7d66c0091ed91f6c396ca0fb2.zip
cpython-73104fa1e6a791f7d66c0091ed91f6c396ca0fb2.tar.gz
cpython-73104fa1e6a791f7d66c0091ed91f6c396ca0fb2.tar.bz2
bpo-35345: Remove platform.popen() (GH-10781)
Remove platform.popen() function, it was deprecated since Python 3.3: use os.popen() instead. Rename also the "Removed" section to "API and Feature Removals" of What's New in Python 3.8.
Diffstat (limited to 'Lib/test/test_platform.py')
-rw-r--r--Lib/test/test_platform.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index c92da90..686f454 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -3,9 +3,7 @@ import platform
import subprocess
import sys
import sysconfig
-import tempfile
import unittest
-import warnings
from test import support
@@ -316,37 +314,6 @@ class PlatformTest(unittest.TestCase):
self.assertLess(V('1.13++'), V('5.5.kw'))
self.assertLess(V('0.960923'), V('2.2beta29'))
- def test_popen(self):
- mswindows = (sys.platform == "win32")
-
- if mswindows:
- command = '"{}" -c "print(\'Hello\')"'.format(sys.executable)
- else:
- command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
- 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:
- command = '"{}" -c "import sys; data=sys.stdin.read(); exit(len(data))"'
- else:
- command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'"
- command = command.format(sys.executable)
- 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))
if __name__ == '__main__':
unittest.main()