Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_tarfile.PaxReadTest Class Reference
Inheritance diagram for test.test_tarfile.PaxReadTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_tarfile.PaxReadTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_pax_global_headers
def test_pax_number_fields
def test_read_longname
def test_read_longlink
def test_truncated_longname
def test_header_offset
def setUp
def tearDown

Public Attributes

 tar

Static Public Attributes

string subdir = "pax"
 longnametype = tarfile.XHDTYPE
 tarname = tarname
string mode = "r:"

Detailed Description

Definition at line 719 of file test_tarfile.py.


Member Function Documentation

def test.test_tarfile.ReadTest.setUp (   self) [inherited]

Definition at line 43 of file test_tarfile.py.

00043 
00044     def setUp(self):
00045         self.tar = tarfile.open(self.tarname, mode=self.mode, encoding="iso8859-1")

Here is the caller graph for this function:

def test.test_tarfile.ReadTest.tearDown (   self) [inherited]

Definition at line 46 of file test_tarfile.py.

00046 
00047     def tearDown(self):
00048         self.tar.close()
00049 

Here is the caller graph for this function:

Definition at line 654 of file test_tarfile.py.

00654 
00655     def test_header_offset(self):
00656         # Test if the start offset of the TarInfo object includes
00657         # the preceding extended header.
00658         longname = self.subdir + "/" + "123/" * 125 + "longname"
00659         offset = self.tar.getmember(longname).offset
00660         with open(tarname, "rb") as fobj:
00661             fobj.seek(offset)
00662             tarinfo = tarfile.TarInfo.frombuf(fobj.read(512), "iso8859-1", "strict")
00663             self.assertEqual(tarinfo.type, self.longnametype)
00664 

Here is the call graph for this function:

Definition at line 724 of file test_tarfile.py.

00724 
00725     def test_pax_global_headers(self):
00726         tar = tarfile.open(tarname, encoding="iso8859-1")
00727         try:
00728             tarinfo = tar.getmember("pax/regtype1")
00729             self.assertEqual(tarinfo.uname, "foo")
00730             self.assertEqual(tarinfo.gname, "bar")
00731             self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
00732 
00733             tarinfo = tar.getmember("pax/regtype2")
00734             self.assertEqual(tarinfo.uname, "")
00735             self.assertEqual(tarinfo.gname, "bar")
00736             self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
00737 
00738             tarinfo = tar.getmember("pax/regtype3")
00739             self.assertEqual(tarinfo.uname, "tarfile")
00740             self.assertEqual(tarinfo.gname, "tarfile")
00741             self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
00742         finally:
00743             tar.close()

Here is the call graph for this function:

Definition at line 744 of file test_tarfile.py.

00744 
00745     def test_pax_number_fields(self):
00746         # All following number fields are read from the pax header.
00747         tar = tarfile.open(tarname, encoding="iso8859-1")
00748         try:
00749             tarinfo = tar.getmember("pax/regtype4")
00750             self.assertEqual(tarinfo.size, 7011)
00751             self.assertEqual(tarinfo.uid, 123)
00752             self.assertEqual(tarinfo.gid, 123)
00753             self.assertEqual(tarinfo.mtime, 1041808783.0)
00754             self.assertEqual(type(tarinfo.mtime), float)
00755             self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
00756             self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
00757         finally:
00758             tar.close()
00759 

Here is the call graph for this function:

Definition at line 637 of file test_tarfile.py.

00637 
00638     def test_read_longlink(self):
00639         longname = self.subdir + "/" + "123/" * 125 + "longname"
00640         longlink = self.subdir + "/" + "123/" * 125 + "longlink"
00641         try:
00642             tarinfo = self.tar.getmember(longlink)
00643         except KeyError:
00644             self.fail("longlink not found")
00645         self.assertTrue(tarinfo.linkname == longname, "linkname wrong")

Here is the call graph for this function:

Definition at line 628 of file test_tarfile.py.

00628 
00629     def test_read_longname(self):
00630         # Test reading of longname (bug #1471427).
00631         longname = self.subdir + "/" + "123/" * 125 + "longname"
00632         try:
00633             tarinfo = self.tar.getmember(longname)
00634         except KeyError:
00635             self.fail("longname not found")
00636         self.assertTrue(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")

Here is the call graph for this function:

Definition at line 646 of file test_tarfile.py.

00646 
00647     def test_truncated_longname(self):
00648         longname = self.subdir + "/" + "123/" * 125 + "longname"
00649         tarinfo = self.tar.getmember(longname)
00650         offset = tarinfo.offset
00651         self.tar.fileobj.seek(offset)
00652         fobj = io.BytesIO(self.tar.fileobj.read(3 * 512))
00653         self.assertRaises(tarfile.ReadError, tarfile.open, name="foo.tar", fileobj=fobj)

Here is the call graph for this function:


Member Data Documentation

Definition at line 722 of file test_tarfile.py.

string test.test_tarfile.ReadTest.mode = "r:" [static, inherited]

Definition at line 721 of file test_tarfile.py.

Reimplemented in test.test_tarfile.MemberReadTest.

Definition at line 44 of file test_tarfile.py.


The documentation for this class was generated from the following file: