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
|
@ -5650,9 +5650,7 @@ class MiscTestCase(unittest.TestCase):
|
|||
# why the test does this, but in any case we save the current locale
|
||||
# first and restore it at the end.
|
||||
def setUpModule():
|
||||
cm = support.run_with_locale('LC_ALL', '')
|
||||
cm.__enter__()
|
||||
unittest.addModuleCleanup(cm.__exit__, None, None, None)
|
||||
unittest.enterModuleContext(support.run_with_locale('LC_ALL', ''))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue