diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-05-08 17:49:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 17:49:09 +0300 |
commit | 086c6b1b0fe8d47ebd15512d7bdcb64c60a360f0 (patch) | |
tree | a7b1eaf75879c3fded1b946b2331f6a45dfc8fc7 /Lib/test/test_argparse.py | |
parent | 8f293180791f2836570bdfc29aadba04a538d435 (diff) | |
download | cpython-086c6b1b0fe8d47ebd15512d7bdcb64c60a360f0.tar.gz cpython-086c6b1b0fe8d47ebd15512d7bdcb64c60a360f0.zip |
bpo-45046: Support context managers in unittest (GH-28045)
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 8509deb93f1..273db45c00f 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -41,9 +41,8 @@ class TestCase(unittest.TestCase): # The tests assume that line wrapping occurs at 80 columns, but this # behaviour can be overridden by setting the COLUMNS environment # variable. To ensure that this width is used, set COLUMNS to 80. - env = os_helper.EnvironmentVarGuard() + env = self.enterContext(os_helper.EnvironmentVarGuard()) env['COLUMNS'] = '80' - self.addCleanup(env.__exit__) class TempDirMixin(object): @@ -3428,9 +3427,8 @@ class TestShortColumns(HelpTestCase): but we don't want any exceptions thrown in such cases. Only ugly representation. ''' def setUp(self): - env = os_helper.EnvironmentVarGuard() + env = self.enterContext(os_helper.EnvironmentVarGuard()) env.set("COLUMNS", '15') - self.addCleanup(env.__exit__) parser_signature = TestHelpBiggerOptionals.parser_signature argument_signatures = TestHelpBiggerOptionals.argument_signatures |