Back to index

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

List of all members.

Public Member Functions

def test_stream_padding
def test_file_mode
def test_fileobj_no_close

Static Public Attributes

string mode = "w|bz2"

Detailed Description

Definition at line 1716 of file test_tarfile.py.


Member Function Documentation

Definition at line 1086 of file test_tarfile.py.

01086 
01087     def test_file_mode(self):
01088         # Test for issue #8464: Create files with correct
01089         # permissions.
01090         if sys.platform == "win32" or not hasattr(os, "umask"):
01091             return
01092 
01093         if os.path.exists(tmpname):
01094             os.remove(tmpname)
01095 
01096         original_umask = os.umask(0o022)
01097         try:
01098             tar = tarfile.open(tmpname, self.mode)
01099             tar.close()
01100             mode = os.stat(tmpname).st_mode & 0o777
01101             self.assertEqual(mode, 0o644, "wrong file permissions")
01102         finally:
01103             os.umask(original_umask)
01104 

Here is the call graph for this function:

Definition at line 764 of file test_tarfile.py.

00764 
00765     def test_fileobj_no_close(self):
00766         fobj = io.BytesIO()
00767         tar = tarfile.open(fileobj=fobj, mode=self.mode)
00768         tar.addfile(tarfile.TarInfo("foo"))
00769         tar.close()
00770         self.assertTrue(fobj.closed is False, "external fileobjs must never closed")
00771 

Here is the call graph for this function:

Definition at line 1064 of file test_tarfile.py.

01064 
01065     def test_stream_padding(self):
01066         # Test for bug #1543303.
01067         tar = tarfile.open(tmpname, self.mode)
01068         tar.close()
01069 
01070         if self.mode.endswith("gz"):
01071             with gzip.GzipFile(tmpname) as fobj:
01072                 data = fobj.read()
01073         elif self.mode.endswith("bz2"):
01074             dec = bz2.BZ2Decompressor()
01075             with open(tmpname, "rb") as fobj:
01076                 data = fobj.read()
01077             data = dec.decompress(data)
01078             self.assertTrue(len(dec.unused_data) == 0,
01079                     "found trailing data")
01080         else:
01081             with open(tmpname, "rb") as fobj:
01082                 data = fobj.read()
01083 
01084         self.assertTrue(data.count(b"\0") == tarfile.RECORDSIZE,
01085                          "incorrect zero padding")

Here is the call graph for this function:


Member Data Documentation

Reimplemented from test.test_tarfile.StreamWriteTest.

Definition at line 1717 of file test_tarfile.py.


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