bpo-37224: Improve test__xxsubinterpreters.DestroyTests (GH-18058)

Adds an additional assertion check based on a race condition for `test__xxsubinterpreters.DestroyTests.test_still_running` discovered in the bpo issue.

https://bugs.python.org/issue37224
(cherry picked from commit f03a8f8d50)

Co-authored-by: Kyle Stanley <aeros167@gmail.com>
This commit is contained in:
Miss Islington (bot) 2020-02-04 07:31:19 -08:00 committed by GitHub
parent a0389ba84b
commit 9a740b6c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -759,7 +759,11 @@ class DestroyTests(TestBase):
main, = interpreters.list_all() main, = interpreters.list_all()
interp = interpreters.create() interp = interpreters.create()
with _running(interp): with _running(interp):
with self.assertRaises(RuntimeError): self.assertTrue(interpreters.is_running(interp),
msg=f"Interp {interp} should be running before destruction.")
with self.assertRaises(RuntimeError,
msg=f"Should not be able to destroy interp {interp} while it's still running."):
interpreters.destroy(interp) interpreters.destroy(interp)
self.assertTrue(interpreters.is_running(interp)) self.assertTrue(interpreters.is_running(interp))