]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-107446: Fix test_inspect.test_class_with_method_from_other_module when ran multipl...
authorTian Gao <gaogaotiantian@hotmail.com>
Thu, 3 Aug 2023 15:04:03 +0000 (07:04 -0800)
committerGitHub <noreply@github.com>
Thu, 3 Aug 2023 15:04:03 +0000 (15:04 +0000)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Lib/test/test_inspect.py

index 3fbfc073255532c8847cb02697fad6ff5228766d..5c31748ce2caacdb212c763066559c8b1bffae1c 100644 (file)
@@ -990,6 +990,9 @@ class TestBuggyCases(GetSourceBase):
             with DirsOnSysPath(tempdir):
                 import inspect_actual
                 self.assertIn("correct", inspect.getsource(inspect_actual.A))
+                # Remove the module from sys.modules to force it to be reloaded.
+                # This is necessary when the test is run multiple times.
+                sys.modules.pop("inspect_actual")
 
     @unittest.skipIf(
         support.is_emscripten or support.is_wasi,