Browse Source

[1828] Close open handles when done using them (contd.)

Mukund Sivaraman 13 years ago
parent
commit
eae421b481
2 changed files with 10 additions and 3 deletions
  1. 4 0
      src/bin/msgq/tests/msgq_test.py
  2. 6 3
      src/bin/tests/process_rename_test.py.in

+ 4 - 0
src/bin/msgq/tests/msgq_test.py

@@ -155,6 +155,8 @@ class SendNonblock(unittest.TestCase):
                 sender(msgq, write)
         except socket.error:
             pass
+        read.close()
+        write.close()
 
     def test_infinite_sendmsg(self):
         """
@@ -217,6 +219,8 @@ class SendNonblock(unittest.TestCase):
                 finally:
                     os.kill(queue_pid, signal.SIGTERM)
         self.terminate_check(run)
+        queue.close()
+        out.close()
 
     def test_small_sends(self):
         """

+ 6 - 3
src/bin/tests/process_rename_test.py.in

@@ -25,7 +25,9 @@ class TestRename(unittest.TestCase):
     def __scan(self, directory, script, fun):
         # Scan one script if it contains call to the renaming function
         filename = os.path.join(directory, script)
-        data = ''.join(open(filename).readlines())
+        fd = open(filename)
+        data = ''.join(fd.readlines())
+        fd.close()
         prettyname = 'src' + filename[filename.rfind('../') + 2:]
         self.assertTrue(fun.search(data),
             "Didn't find a call to isc.util.process.rename in " + prettyname)
@@ -53,8 +55,9 @@ class TestRename(unittest.TestCase):
         # Find all Makefile and extract names of scripts
         for (d, _, fs) in os.walk('@top_builddir@'):
             if 'Makefile' in fs:
-                makefile = ''.join(open(os.path.join(d,
-                    "Makefile")).readlines())
+                fd = open(os.path.join(d, "Makefile"))
+                makefile = ''.join(fd.readlines())
+                fd.close()
                 for (var, _) in lines.findall(re.sub(excluded_lines, '',
                                                      makefile)):
                     for (script, _) in scripts.findall(var):