mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Use support.change_cwd() in tests.
This commit is contained in:
parent
ef920d6d5e
commit
2a23adf440
8 changed files with 33 additions and 99 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue