From 77a06200774954417b8d09b36007898f2dca6f77 2013-09-19 22:21:13
From: Thomas Kluyver <takowl@gmail.com>
Date: 2013-09-19 22:21:13
Subject: [PATCH] Fix cleanup of test controller

---

diff --git a/IPython/testing/iptestcontroller.py b/IPython/testing/iptestcontroller.py
index 68b545f..b8d1a89 100644
--- a/IPython/testing/iptestcontroller.py
+++ b/IPython/testing/iptestcontroller.py
@@ -95,7 +95,7 @@ class IPTestController(object):
             subprocess.call(["coverage", "xml", "-o", self.coverage_xml])
         return retcode
 
-    def cleanup(self):
+    def cleanup_process(self):
         """Cleanup on exit by killing any leftover processes."""
         subp = self.process
         if subp is None or (subp.poll() is not None):
@@ -118,7 +118,10 @@ class IPTestController(object):
         if subp.poll() is None:
             # The process did not die...
             print('... failed. Manual cleanup may be required.')
-        
+    
+    def cleanup(self):
+        "Kill process if it's still alive, and clean up temporary directories"
+        self.cleanup_process()
         for td in self.dirs:
             td.cleanup()
     
diff --git a/IPython/utils/tempdir.py b/IPython/utils/tempdir.py
index 0aa7440..0f27889 100644
--- a/IPython/utils/tempdir.py
+++ b/IPython/utils/tempdir.py
@@ -5,6 +5,8 @@ This is copied from the stdlib and will be standard in Python 3.2 and onwards.
 from __future__ import print_function
 
 import os as _os
+import warnings as _warnings
+import sys as _sys
 
 # This code should only be used in Python versions < 3.2, since after that we
 # can rely on the stdlib itself.
@@ -49,7 +51,7 @@ except ImportError:
                 self._closed = True
                 if _warn:
                     self._warn("Implicitly cleaning up {!r}".format(self),
-                               ResourceWarning)
+                               Warning)
 
         def __exit__(self, exc, value, tb):
             self.cleanup()
@@ -69,6 +71,7 @@ except ImportError:
         _remove = staticmethod(_os.remove)
         _rmdir = staticmethod(_os.rmdir)
         _os_error = _os.error
+        _warn = _warnings.warn
 
         def _rmtree(self, path):
             # Essentially a stripped down version of shutil.rmtree.  We can't