diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-03 12:54:07 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-03 12:54:07 (GMT) |
commit | 1dfd3803064f2ee4b6e0bae3c60ca39e5f3919ca (patch) | |
tree | 4b534f4dd099ef80b48a795a8c3db33ce85c94c0 /Lib/test/test_platform.py | |
parent | 7b3b20ad29be6d77608b4bd9cd09b61b67783bcf (diff) | |
download | cpython-1dfd3803064f2ee4b6e0bae3c60ca39e5f3919ca.zip cpython-1dfd3803064f2ee4b6e0bae3c60ca39e5f3919ca.tar.gz cpython-1dfd3803064f2ee4b6e0bae3c60ca39e5f3919ca.tar.bz2 |
Issue #11377: Deprecate platform.popen() and reimplement it with os.popen().
Diffstat (limited to 'Lib/test/test_platform.py')
-rw-r--r-- | Lib/test/test_platform.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 7dd7eef..1ab0d9c 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -243,6 +243,25 @@ class PlatformTest(unittest.TestCase): ): self.assertEqual(platform._parse_release_file(input), output) + def test_popen(self): + command = "'{}' -c 'print(\"Hello\")'".format(sys.executable) + with platform.popen(command) as stdout: + hello = stdout.read().strip() + stdout.close() + self.assertEqual(hello, "Hello") + + command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'".format(sys.executable) + data = 'plop' + 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(): support.run_unittest( |