Cleanup test_tarfile, and use check_warnings.

This commit is contained in:
Florent Xicluna 2010-03-20 22:26:42 +00:00
parent db4a321fea
commit fc5f6a7f40
1 changed files with 12 additions and 9 deletions

View File

@ -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,10 +707,11 @@ 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")
with test_support.check_warnings(("use the filter argument",
DeprecationWarning)):
tar.add(tempdir, arcname="empty_dir", exclude=exclude)
tar.close()
@ -889,9 +890,11 @@ 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, \
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):
@ -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()