Back to index

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

List of all members.

Public Member Functions

def test_pax_global_header
def test_pax_extended_header
def test_longname_1023
def test_longname_1024
def test_longname_1025
def test_longlink_1023
def test_longlink_1024
def test_longlink_1025
def test_longnamelink_1023
def test_longnamelink_1024
def test_longnamelink_1025

Private Member Functions

def _test

Detailed Description

Definition at line 1228 of file test_tarfile.py.


Member Function Documentation

def test.test_tarfile.PaxWriteTest._test (   self,
  name,
  link = None 
) [private]

Reimplemented from test.test_tarfile.GNUWriteTest.

Definition at line 1230 of file test_tarfile.py.

01230 
01231     def _test(self, name, link=None):
01232         # See GNUWriteTest.
01233         tarinfo = tarfile.TarInfo(name)
01234         if link:
01235             tarinfo.linkname = link
01236             tarinfo.type = tarfile.LNKTYPE
01237 
01238         tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
01239         try:
01240             tar.addfile(tarinfo)
01241         finally:
01242             tar.close()
01243 
01244         tar = tarfile.open(tmpname)
01245         try:
01246             if link:
01247                 l = tar.getmembers()[0].linkname
01248                 self.assertTrue(link == l, "PAX longlink creation failed")
01249             else:
01250                 n = tar.getmembers()[0].name
01251                 self.assertTrue(name == n, "PAX longname creation failed")
01252         finally:
01253             tar.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1167 of file test_tarfile.py.

01167 
01168     def test_longlink_1023(self):
01169         self._test("name", ("longlnk/" * 127) + "longlnk")

Here is the call graph for this function:

Definition at line 1170 of file test_tarfile.py.

01170 
01171     def test_longlink_1024(self):
01172         self._test("name", ("longlnk/" * 127) + "longlink")

Here is the call graph for this function:

Definition at line 1173 of file test_tarfile.py.

01173 
01174     def test_longlink_1025(self):
01175         self._test("name", ("longlnk/" * 127) + "longlink_")

Here is the call graph for this function:

Definition at line 1158 of file test_tarfile.py.

01158 
01159     def test_longname_1023(self):
01160         self._test(("longnam/" * 127) + "longnam")

Here is the call graph for this function:

Definition at line 1161 of file test_tarfile.py.

01161 
01162     def test_longname_1024(self):
01163         self._test(("longnam/" * 127) + "longname")

Here is the call graph for this function:

Definition at line 1164 of file test_tarfile.py.

01164 
01165     def test_longname_1025(self):
01166         self._test(("longnam/" * 127) + "longname_")

Here is the call graph for this function:

Definition at line 1176 of file test_tarfile.py.

01176 
01177     def test_longnamelink_1023(self):
01178         self._test(("longnam/" * 127) + "longnam",
01179                    ("longlnk/" * 127) + "longlnk")

Here is the call graph for this function:

Definition at line 1180 of file test_tarfile.py.

01180 
01181     def test_longnamelink_1024(self):
01182         self._test(("longnam/" * 127) + "longname",
01183                    ("longlnk/" * 127) + "longlink")

Here is the call graph for this function:

Definition at line 1184 of file test_tarfile.py.

01184 
01185     def test_longnamelink_1025(self):
01186         self._test(("longnam/" * 127) + "longname_",
01187                    ("longlnk/" * 127) + "longlink_")
01188 

Here is the call graph for this function:

Definition at line 1286 of file test_tarfile.py.

01286 
01287     def test_pax_extended_header(self):
01288         # The fields from the pax header have priority over the
01289         # TarInfo.
01290         pax_headers = {"path": "foo", "uid": "123"}
01291 
01292         tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="iso8859-1")
01293         try:
01294             t = tarfile.TarInfo()
01295             t.name = "\xe4\xf6\xfc" # non-ASCII
01296             t.uid = 8**8 # too large
01297             t.pax_headers = pax_headers
01298             tar.addfile(t)
01299         finally:
01300             tar.close()
01301 
01302         tar = tarfile.open(tmpname, encoding="iso8859-1")
01303         try:
01304             t = tar.getmembers()[0]
01305             self.assertEqual(t.pax_headers, pax_headers)
01306             self.assertEqual(t.name, "foo")
01307             self.assertEqual(t.uid, 123)
01308         finally:
01309             tar.close()
01310 

Here is the call graph for this function:

Definition at line 1254 of file test_tarfile.py.

01254 
01255     def test_pax_global_header(self):
01256         pax_headers = {
01257                 "foo": "bar",
01258                 "uid": "0",
01259                 "mtime": "1.23",
01260                 "test": "\xe4\xf6\xfc",
01261                 "\xe4\xf6\xfc": "test"}
01262 
01263         tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
01264                 pax_headers=pax_headers)
01265         try:
01266             tar.addfile(tarfile.TarInfo("test"))
01267         finally:
01268             tar.close()
01269 
01270         # Test if the global header was written correctly.
01271         tar = tarfile.open(tmpname, encoding="iso8859-1")
01272         try:
01273             self.assertEqual(tar.pax_headers, pax_headers)
01274             self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
01275             # Test if all the fields are strings.
01276             for key, val in tar.pax_headers.items():
01277                 self.assertTrue(type(key) is not bytes)
01278                 self.assertTrue(type(val) is not bytes)
01279                 if key in tarfile.PAX_NUMBER_FIELDS:
01280                     try:
01281                         tarfile.PAX_NUMBER_FIELDS[key](val)
01282                     except (TypeError, ValueError):
01283                         self.fail("unable to convert pax header field")
01284         finally:
01285             tar.close()

Here is the call graph for this function:


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