diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-06 11:13:25 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-06 11:13:25 (GMT) |
commit | 2a23adf4405bcd903aabf445dd54867d95f494a1 (patch) | |
tree | fc4c823138cb505c180873976bc0a41ac3a1f6d5 /Lib/test/test_unicode_file.py | |
parent | ef920d6d5e38cebd51b17001d614b55b1c468041 (diff) | |
download | cpython-2a23adf4405bcd903aabf445dd54867d95f494a1.zip cpython-2a23adf4405bcd903aabf445dd54867d95f494a1.tar.gz cpython-2a23adf4405bcd903aabf445dd54867d95f494a1.tar.bz2 |
Use support.change_cwd() in tests.
Diffstat (limited to 'Lib/test/test_unicode_file.py')
-rw-r--r-- | Lib/test/test_unicode_file.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py index faa8da3..e4709a1 100644 --- a/Lib/test/test_unicode_file.py +++ b/Lib/test/test_unicode_file.py @@ -5,7 +5,7 @@ import os, glob, time, shutil import unicodedata import unittest -from test.support import (run_unittest, rmtree, +from test.support import (run_unittest, rmtree, change_cwd, TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODABLE, create_empty_file) if not os.path.supports_unicode_filenames: @@ -82,13 +82,11 @@ class TestUnicodeFiles(unittest.TestCase): self.assertFalse(os.path.exists(filename2 + '.new')) def _do_directory(self, make_name, chdir_name): - cwd = os.getcwd() if os.path.isdir(make_name): rmtree(make_name) os.mkdir(make_name) try: - os.chdir(chdir_name) - try: + with change_cwd(chdir_name): cwd_result = os.getcwd() name_result = make_name @@ -96,8 +94,6 @@ class TestUnicodeFiles(unittest.TestCase): name_result = unicodedata.normalize("NFD", name_result) self.assertEqual(os.path.basename(cwd_result),name_result) - finally: - os.chdir(cwd) finally: os.rmdir(make_name) |