Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg). This changes all uses of deprecated tempfile functions to
the recommended ones.
diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py
index 5ea08bc..56d4e7c 100644
--- a/Lib/test/test_commands.py
+++ b/Lib/test/test_commands.py
@@ -24,10 +24,17 @@
self.assertEquals(getoutput('echo xyzzy'), 'xyzzy')
self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy'))
- # we use mktemp in the next line to get a filename which we
- # _know_ won't exist. This is guaranteed to fail.
- status, output = getstatusoutput('cat ' + tempfile.mktemp())
- self.assertNotEquals(status, 0)
+ # we use mkdtemp in the next line to create an empty directory
+ # under our exclusive control; from that, we can invent a pathname
+ # that we _know_ won't exist. This is guaranteed to fail.
+ try:
+ dir = tempfile.mkdtemp()
+ name = os.path.join(dir, "foo")
+
+ status, output = getstatusoutput('cat ' + name)
+ self.assertNotEquals(status, 0)
+ finally:
+ os.rmdir(dir)
def test_getstatus(self):
# This pattern should match 'ls -ld /.' on any posix