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().
(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
|
@ -19,8 +19,7 @@ class Test_OSXSupport(unittest.TestCase):
|
|||
self.maxDiff = None
|
||||
self.prog_name = 'bogus_program_xxxx'
|
||||
self.temp_path_dir = os.path.abspath(os.getcwd())
|
||||
self.env = os_helper.EnvironmentVarGuard()
|
||||
self.addCleanup(self.env.__exit__)
|
||||
self.env = self.enterContext(os_helper.EnvironmentVarGuard())
|
||||
for cv in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||
'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC',
|
||||
'CXX', 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue