mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +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().
This commit is contained in:
parent
8f29318079
commit
086c6b1b0f
26 changed files with 307 additions and 92 deletions
|
@ -1593,8 +1593,7 @@ class LocalServerTests(unittest.TestCase):
|
|||
self.background.start()
|
||||
self.addCleanup(self.background.join)
|
||||
|
||||
self.nntp = NNTP(socket_helper.HOST, port, usenetrc=False).__enter__()
|
||||
self.addCleanup(self.nntp.__exit__, None, None, None)
|
||||
self.nntp = self.enterContext(NNTP(socket_helper.HOST, port, usenetrc=False))
|
||||
|
||||
def run_server(self, sock):
|
||||
# Could be generalized to handle more commands in separate methods
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue