From a2582e6a7bb2418baa7f54e035b443baa6d56095 2018-06-13 17:09:57
From: Matthias Bussonnier <bussonniermatthias@gmail.com>
Date: 2018-06-13 17:09:57
Subject: [PATCH] Correctly tearDown some test cases with multiple inheritance.

On Python 3.7+ this leads to Resources warnings at testing suite
shutdown. Fix this at least for IPython.core.tests.test_interactiveshell.

---

diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py
index 12bd380..b40ef51 100644
--- a/IPython/core/tests/test_interactiveshell.py
+++ b/IPython/core/tests/test_interactiveshell.py
@@ -546,6 +546,10 @@ class ExitCodeChecks(tt.TempFileMixin):
             else:
                 del os.environ['SHELL']
 
+    def tearDown(self):
+        tt.TempFileMixin.tearDown(self)
+
+
 class TestSystemRaw(unittest.TestCase, ExitCodeChecks):
     system = ip.system_raw
 
@@ -566,10 +570,16 @@ class TestSystemRaw(unittest.TestCase, ExitCodeChecks):
                       "keyboard interrupt from subprocess.call")
         self.assertEqual(ip.user_ns['_exit_code'], -signal.SIGINT)
 
+    def tearDown(self):
+        ExitCodeChecks.tearDown(self)
+
 # TODO: Exit codes are currently ignored on Windows.
 class TestSystemPipedExitCode(unittest.TestCase, ExitCodeChecks):
     system = ip.system_piped
 
+    def tearDown(self):
+        ExitCodeChecks.tearDown(self)
+
     @skip_win32
     def test_exit_code_ok(self):
         ExitCodeChecks.test_exit_code_ok(self)
@@ -594,6 +604,9 @@ class TestModules(unittest.TestCase, tt.TempFileMixin):
         out = "False\nFalse\nFalse\n"
         tt.ipexec_validate(self.fname, out)
 
+    def tearDown(self):
+        tt.TempFileMixin.tearDown(self)
+
 class Negator(ast.NodeTransformer):
     """Negates all number literals in an AST."""
     def visit_Num(self, node):
diff --git a/IPython/core/tests/test_shellapp.py b/IPython/core/tests/test_shellapp.py
index 8134269..ca15c09 100644
--- a/IPython/core/tests/test_shellapp.py
+++ b/IPython/core/tests/test_shellapp.py
@@ -27,6 +27,9 @@ SQLITE_NOT_AVAILABLE_ERROR = ('WARNING: IPython History requires SQLite,'
 class TestFileToRun(unittest.TestCase, tt.TempFileMixin):
     """Test the behavior of the file_to_run parameter."""
 
+    def tearDown(self):
+        tt.TempFileMixin.tearDown(self)
+
     def test_py_script_file_attribute(self):
         """Test that `__file__` is set when running `ipython file.py`"""
         src = "print(__file__)\n"