diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-09-28 10:33:14 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-09-28 10:33:14 (GMT) |
commit | 16a1f281942a5bd1f00d038187cad970c1d173e1 (patch) | |
tree | eb7b913fb7a87e2a7f2222c077e12331d4106128 /Lib/test | |
parent | d351706950a04a785eb37fe907610d3235719bb4 (diff) | |
download | cpython-16a1f281942a5bd1f00d038187cad970c1d173e1.zip cpython-16a1f281942a5bd1f00d038187cad970c1d173e1.tar.gz cpython-16a1f281942a5bd1f00d038187cad970c1d173e1.tar.bz2 |
Issue #25249: Remove unneeded mkstemp helper in test_subprocess
The helper was added in 76641824cf05 11 years ago and it can be
removed now since all supported Python versions have tempfile.mkstemp().
Patch by Nir Soffer.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_subprocess.py | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index e1b8c36..2ce5951 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -37,16 +37,6 @@ else: SETBINARY = '' -try: - mkstemp = tempfile.mkstemp -except AttributeError: - # tempfile.mkstemp is not available - def mkstemp(): - """Replacement for mkstemp, calling mktemp.""" - fname = tempfile.mktemp() - return os.open(fname, os.O_RDWR|os.O_CREAT), fname - - class BaseTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test @@ -1150,9 +1140,9 @@ class ProcessTestCase(BaseTestCase): def test_handles_closed_on_exception(self): # If CreateProcess exits with an error, ensure the # duplicate output handles are released - ifhandle, ifname = mkstemp() - ofhandle, ofname = mkstemp() - efhandle, efname = mkstemp() + ifhandle, ifname = tempfile.mkstemp() + ofhandle, ofname = tempfile.mkstemp() + efhandle, efname = tempfile.mkstemp() try: subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle, stderr=efhandle) @@ -1428,7 +1418,7 @@ class POSIXProcessTestCase(BaseTestCase): def test_args_string(self): # args is a string - fd, fname = mkstemp() + fd, fname = tempfile.mkstemp() # reopen in text mode with open(fd, "w", errors="surrogateescape") as fobj: fobj.write("#!/bin/sh\n") @@ -1473,7 +1463,7 @@ class POSIXProcessTestCase(BaseTestCase): def test_call_string(self): # call() function with string argument on UNIX - fd, fname = mkstemp() + fd, fname = tempfile.mkstemp() # reopen in text mode with open(fd, "w", errors="surrogateescape") as fobj: fobj.write("#!/bin/sh\n") @@ -1666,7 +1656,7 @@ class POSIXProcessTestCase(BaseTestCase): def test_remapping_std_fds(self): # open up some temporary files - temps = [mkstemp() for i in range(3)] + temps = [tempfile.mkstemp() for i in range(3)] try: temp_fds = [fd for fd, fname in temps] @@ -1711,7 +1701,7 @@ class POSIXProcessTestCase(BaseTestCase): def check_swap_fds(self, stdin_no, stdout_no, stderr_no): # open up some temporary files - temps = [mkstemp() for i in range(3)] + temps = [tempfile.mkstemp() for i in range(3)] temp_fds = [fd for fd, fname in temps] try: # unlink the files -- we won't need to reopen them @@ -2442,7 +2432,7 @@ class CommandsWithSpaces (BaseTestCase): def setUp(self): super().setUp() - f, fname = mkstemp(".py", "te st") + f, fname = tempfile.mkstemp(".py", "te st") self.fname = fname.lower () os.write(f, b"import sys;" b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))" |