mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +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
|
@ -128,8 +128,7 @@ class PollTests(unittest.TestCase):
|
|||
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
|
||||
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
|
||||
bufsize=0)
|
||||
proc.__enter__()
|
||||
self.addCleanup(proc.__exit__, None, None, None)
|
||||
self.enterContext(proc)
|
||||
p = proc.stdout
|
||||
pollster = select.poll()
|
||||
pollster.register( p, select.POLLIN )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue