mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +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
|
@ -41,9 +41,7 @@ class BuildExtTestCase(TempdirManager,
|
|||
# bpo-30132: On Windows, a .pdb file may be created in the current
|
||||
# working directory. Create a temporary working directory to cleanup
|
||||
# everything at the end of the test.
|
||||
change_cwd = os_helper.change_cwd(self.tmp_dir)
|
||||
change_cwd.__enter__()
|
||||
self.addCleanup(change_cwd.__exit__, None, None, None)
|
||||
self.enterContext(os_helper.change_cwd(self.tmp_dir))
|
||||
|
||||
def tearDown(self):
|
||||
import site
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue