Back to index

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

List of all members.

Public Member Functions

def test_sparse_file_old
def test_sparse_file_00
def test_sparse_file_01
def test_sparse_file_10
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 = "gnu"
 longnametype = tarfile.GNUTYPE_LONGNAME
 tarname = tarname
string mode = "r:"

Private Member Functions

def _test_sparse_file

Static Private Member Functions

def _fs_supports_holes

Detailed Description

Definition at line 665 of file test_tarfile.py.


Member Function Documentation

Definition at line 702 of file test_tarfile.py.

00702 
00703     def _fs_supports_holes():
00704         # Return True if the platform knows the st_blocks stat attribute and
00705         # uses st_blocks units of 512 bytes, and if the filesystem is able to
00706         # store holes in files.
00707         if sys.platform == "linux2":
00708             # Linux evidentially has 512 byte st_blocks units.
00709             name = os.path.join(TEMPDIR, "sparse-test")
00710             with open(name, "wb") as fobj:
00711                 fobj.seek(4096)
00712                 fobj.truncate()
00713             s = os.stat(name)
00714             os.remove(name)
00715             return s.st_blocks == 0
00716         else:
00717             return False
00718 

Here is the caller graph for this function:

def test.test_tarfile.GNUReadTest._test_sparse_file (   self,
  name 
) [private]

Definition at line 677 of file test_tarfile.py.

00677 
00678     def _test_sparse_file(self, name):
00679         self.tar.extract(name, TEMPDIR)
00680         filename = os.path.join(TEMPDIR, name)
00681         with open(filename, "rb") as fobj:
00682             data = fobj.read()
00683         self.assertEqual(md5sum(data), md5_sparse,
00684                 "wrong md5sum for %s" % name)
00685 
00686         if self._fs_supports_holes():
00687             s = os.stat(filename)
00688             self.assertTrue(s.st_blocks * 512 < s.st_size)

Here is the call graph for this function:

Here is the caller graph for this function:

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 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 692 of file test_tarfile.py.

00692 
00693     def test_sparse_file_00(self):
00694         self._test_sparse_file("gnu/sparse-0.0")

Here is the call graph for this function:

Definition at line 695 of file test_tarfile.py.

00695 
00696     def test_sparse_file_01(self):
00697         self._test_sparse_file("gnu/sparse-0.1")

Here is the call graph for this function:

Definition at line 698 of file test_tarfile.py.

00698 
00699     def test_sparse_file_10(self):
00700         self._test_sparse_file("gnu/sparse-1.0")

Here is the call graph for this function:

Definition at line 689 of file test_tarfile.py.

00689 
00690     def test_sparse_file_old(self):
00691         self._test_sparse_file("gnu/sparse")

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 668 of file test_tarfile.py.

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

Definition at line 667 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: