From 3b0a3293c369f3c3f4753e3cb9172cb4e242af76 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 9 Aug 2002 16:38:32 +0000 Subject: Massive changes from SF 589982 (tempfile.py rewrite, by Zack Weinberg). This changes all uses of deprecated tempfile functions to the recommended ones. --- Lib/test/test_commands.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Lib/test/test_commands.py') 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 -- cgit v1.2.1