Commit 590fe02e authored by Thomas Wouters's avatar Thomas Wouters

CommandTests.testgetoutput():

    Make sure we aren't masking any errors raised in tempfile.mkdtemp() by
    referencing the (then) unbound local 'dir'.
parent 49754af8
...@@ -27,6 +27,7 @@ class CommandTests(unittest.TestCase): ...@@ -27,6 +27,7 @@ class CommandTests(unittest.TestCase):
# we use mkdtemp in the next line to create an empty directory # we use mkdtemp in the next line to create an empty directory
# under our exclusive control; from that, we can invent a pathname # under our exclusive control; from that, we can invent a pathname
# that we _know_ won't exist. This is guaranteed to fail. # that we _know_ won't exist. This is guaranteed to fail.
dir = None
try: try:
dir = tempfile.mkdtemp() dir = tempfile.mkdtemp()
name = os.path.join(dir, "foo") name = os.path.join(dir, "foo")
...@@ -34,7 +35,8 @@ class CommandTests(unittest.TestCase): ...@@ -34,7 +35,8 @@ class CommandTests(unittest.TestCase):
status, output = getstatusoutput('cat ' + name) status, output = getstatusoutput('cat ' + name)
self.assertNotEquals(status, 0) self.assertNotEquals(status, 0)
finally: finally:
os.rmdir(dir) if dir is not None:
os.rmdir(dir)
def test_getstatus(self): def test_getstatus(self):
# This pattern should match 'ls -ld /.' on any posix # This pattern should match 'ls -ld /.' on any posix
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment