Cleanup test_tarfile, and use check_warnings.
This commit is contained in:
parent
db4a321fea
commit
fc5f6a7f40
|
@ -69,7 +69,7 @@ class UstarReadTest(ReadTest):
|
|||
"fileobj.readlines() failed")
|
||||
self.assertTrue(len(lines2) == 114,
|
||||
"fileobj.readlines() failed")
|
||||
self.assertTrue(lines2[83] == \
|
||||
self.assertTrue(lines2[83] ==
|
||||
"I will gladly admit that Python is not the fastest running scripting language.\n",
|
||||
"fileobj.readlines() failed")
|
||||
|
||||
|
@ -707,11 +707,12 @@ class WriteTest(WriteTestBase):
|
|||
name = os.path.join(tempdir, name)
|
||||
open(name, "wb").close()
|
||||
|
||||
def exclude(name):
|
||||
return os.path.isfile(name)
|
||||
exclude = os.path.isfile
|
||||
|
||||
tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
|
||||
tar.add(tempdir, arcname="empty_dir", exclude=exclude)
|
||||
with test_support.check_warnings(("use the filter argument",
|
||||
DeprecationWarning)):
|
||||
tar.add(tempdir, arcname="empty_dir", exclude=exclude)
|
||||
tar.close()
|
||||
|
||||
tar = tarfile.open(tmpname, "r")
|
||||
|
@ -889,10 +890,12 @@ class GNUWriteTest(unittest.TestCase):
|
|||
|
||||
tar = tarfile.open(tmpname)
|
||||
member = tar.next()
|
||||
self.assertFalse(member is None, "unable to read longname member")
|
||||
self.assertTrue(tarinfo.name == member.name and \
|
||||
tarinfo.linkname == member.linkname, \
|
||||
"unable to read longname member")
|
||||
self.assertIsNotNone(member,
|
||||
"unable to read longname member")
|
||||
self.assertEqual(tarinfo.name, member.name,
|
||||
"unable to read longname member")
|
||||
self.assertEqual(tarinfo.linkname, member.linkname,
|
||||
"unable to read longname member")
|
||||
|
||||
def test_longname_1023(self):
|
||||
self._test(("longnam/" * 127) + "longnam")
|
||||
|
@ -994,7 +997,7 @@ class PaxWriteTest(GNUWriteTest):
|
|||
u"test": u"äöü",
|
||||
u"äöü": u"test"}
|
||||
|
||||
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \
|
||||
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
|
||||
pax_headers=pax_headers)
|
||||
tar.addfile(tarfile.TarInfo("test"))
|
||||
tar.close()
|
||||
|
|
Loading…
Reference in New Issue