summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-06 11:13:25 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-06 11:13:25 (GMT)
commit2a23adf4405bcd903aabf445dd54867d95f494a1 (patch)
treefc4c823138cb505c180873976bc0a41ac3a1f6d5 /Lib/test/test_tarfile.py
parentef920d6d5e38cebd51b17001d614b55b1c468041 (diff)
downloadcpython-2a23adf4405bcd903aabf445dd54867d95f494a1.zip
cpython-2a23adf4405bcd903aabf445dd54867d95f494a1.tar.gz
cpython-2a23adf4405bcd903aabf445dd54867d95f494a1.tar.bz2
Use support.change_cwd() in tests.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 8ab7575..3091ce7 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1104,10 +1104,8 @@ class WriteTest(WriteTestBase, unittest.TestCase):
self.assertEqual(tar.getnames(), [],
"added the archive to itself")
- cwd = os.getcwd()
- os.chdir(TEMPDIR)
- tar.add(dstname)
- os.chdir(cwd)
+ with support.change_cwd(TEMPDIR):
+ tar.add(dstname)
self.assertEqual(tar.getnames(), [],
"added the archive to itself")
finally:
@@ -1264,9 +1262,7 @@ class WriteTest(WriteTestBase, unittest.TestCase):
def test_cwd(self):
# Test adding the current working directory.
- cwd = os.getcwd()
- os.chdir(TEMPDIR)
- try:
+ with support.change_cwd(TEMPDIR):
tar = tarfile.open(tmpname, self.mode)
try:
tar.add(".")
@@ -1280,8 +1276,6 @@ class WriteTest(WriteTestBase, unittest.TestCase):
self.assertTrue(t.name.startswith("./"), t.name)
finally:
tar.close()
- finally:
- os.chdir(cwd)
def test_open_nonwritable_fileobj(self):
for exctype in OSError, EOFError, RuntimeError: