gh-107446: Fix test_inspect.test_class_with_method_from_other_module when ran multiple times (#107451)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Tian Gao 2023-08-03 07:04:03 -08:00 committed by GitHub
parent ed4a978449
commit 14fbd4e6b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View 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,