mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
bpo-45046: Support context managers in unittest (GH-28045)
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
(cherry picked from commit 086c6b1b0f
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
a85bdd7e02
commit
c63c8ac238
26 changed files with 307 additions and 92 deletions
|
@ -338,9 +338,7 @@ class ThreadableTest:
|
|||
self.server_ready.set()
|
||||
|
||||
def _setUp(self):
|
||||
self.wait_threads = threading_helper.wait_threads_exit()
|
||||
self.wait_threads.__enter__()
|
||||
self.addCleanup(self.wait_threads.__exit__, None, None, None)
|
||||
self.enterContext(threading_helper.wait_threads_exit())
|
||||
|
||||
self.server_ready = threading.Event()
|
||||
self.client_ready = threading.Event()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue