summaryrefslogtreecommitdiff
path: root/Lib/test/test_commands.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-09 16:38:32 +0000
committerGuido van Rossum <guido@python.org>2002-08-09 16:38:32 +0000
commit3b0a3293c369f3c3f4753e3cb9172cb4e242af76 (patch)
treee0f9d295c0a2897ddfb7a5bf3b076be70f1492b4 /Lib/test/test_commands.py
parent830a5151c1e2ed4d0c647efb4ad54a9a6c67e4ae (diff)
downloadcpython-git-3b0a3293c369f3c3f4753e3cb9172cb4e242af76.tar.gz
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg). This changes all uses of deprecated tempfile functions to the recommended ones.
Diffstat (limited to 'Lib/test/test_commands.py')
-rw-r--r--Lib/test/test_commands.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py
index 5ea08bc8b4..56d4e7c7a2 100644
--- a/Lib/test/test_commands.py
+++ b/Lib/test/test_commands.py
@@ -24,10 +24,17 @@ class CommandTests(unittest.TestCase):
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