@@ -85,7 +85,7 @@ def test_C_utf8_locale(self):
8585 "LC_CTYPE" : "" ,
8686 "LC_ALL" : "" ,
8787 }
88- for env_var in ( "LC_ALL" , "LC_CTYPE" , "LANG" ) :
88+ for env_var in base_var_dict :
8989 with self .subTest (env_var = env_var ):
9090 var_dict = base_var_dict .copy ()
9191 var_dict [env_var ] = "C.UTF-8"
@@ -112,7 +112,7 @@ def _check_c_locale_coercion(self, expected_fsencoding, coerce_c_locale):
112112 "LC_CTYPE" : "" ,
113113 "LC_ALL" : "" ,
114114 }
115- for env_var in ( "LC_ALL" , "LC_CTYPE" , "LANG" ) :
115+ for env_var in base_var_dict :
116116 for locale_to_set in ("" , "C" , "POSIX" , "invalid.ascii" ):
117117 with self .subTest (env_var = env_var ,
118118 nominal_locale = locale_to_set ,
@@ -161,12 +161,9 @@ def setUp(self):
161161 # This is needed otherwise we get a fatal error:
162162 # "Py_Initialize: Unable to get the locale encoding
163163 # LookupError: no codec search functions registered: can't find encoding"
164- self .oldcwd = os .getcwd ()
164+ self .addCleanup ( os . chdir , os .getcwd () )
165165 os .chdir (basepath )
166166
167- def tearDown (self ):
168- os .chdir (self .oldcwd )
169-
170167 def run_embedded_interpreter (self , * args ):
171168 """Runs a test in the embedded interpreter"""
172169 cmd = [self .test_exe ]
0 commit comments