]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
CommandTests.testgetoutput():
authorThomas Wouters <thomas@python.org>
Tue, 25 Mar 2003 18:50:19 +0000 (18:50 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 25 Mar 2003 18:50:19 +0000 (18:50 +0000)
    Make sure we aren't masking any errors raised in tempfile.mkdtemp() by
    referencing the (then) unbound local 'dir'.

Lib/test/test_commands.py

index ef87d79240f757fa562ed15064feee75754b758c..0f7d15f1849813848e1aa4f2abcd0065fa9bf4c6 100644 (file)
@@ -27,6 +27,7 @@ class CommandTests(unittest.TestCase):
         # 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.
+        dir = None
         try:
             dir = tempfile.mkdtemp()
             name = os.path.join(dir, "foo")
@@ -34,7 +35,8 @@ class CommandTests(unittest.TestCase):
             status, output = getstatusoutput('cat ' + name)
             self.assertNotEquals(status, 0)
         finally:
-            os.rmdir(dir)
+            if dir is not None:
+                os.rmdir(dir)
 
     def test_getstatus(self):
         # This pattern should match 'ls -ld /.' on any posix