aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_gettext.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-05-08 17:49:09 +0300
committerGitHub <noreply@github.com>2022-05-08 17:49:09 +0300
commit086c6b1b0fe8d47ebd15512d7bdcb64c60a360f0 (patch)
treea7b1eaf75879c3fded1b946b2331f6a45dfc8fc7 /Lib/test/test_gettext.py
parent8f293180791f2836570bdfc29aadba04a538d435 (diff)
downloadcpython-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_gettext.py')
-rw-r--r--Lib/test/test_gettext.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index 467652a41f0..1608d1b18e9 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -117,6 +117,7 @@ MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo')
class GettextBaseTest(unittest.TestCase):
def setUp(self):
+ self.addCleanup(os_helper.rmtree, os.path.split(LOCALEDIR)[0])
if not os.path.isdir(LOCALEDIR):
os.makedirs(LOCALEDIR)
with open(MOFILE, 'wb') as fp:
@@ -129,14 +130,10 @@ class GettextBaseTest(unittest.TestCase):
fp.write(base64.decodebytes(UMO_DATA))
with open(MMOFILE, 'wb') as fp:
fp.write(base64.decodebytes(MMO_DATA))
- self.env = os_helper.EnvironmentVarGuard()
+ self.env = self.enterContext(os_helper.EnvironmentVarGuard())
self.env['LANGUAGE'] = 'xx'
gettext._translations.clear()
- def tearDown(self):
- self.env.__exit__()
- del self.env
- os_helper.rmtree(os.path.split(LOCALEDIR)[0])
GNU_MO_DATA_ISSUE_17898 = b'''\
3hIElQAAAAABAAAAHAAAACQAAAAAAAAAAAAAAAAAAAAsAAAAggAAAC0AAAAAUGx1cmFsLUZvcm1z