Back to index

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

List of all members.

Public Member Functions

def test_fileobj_regular_file
def test_fileobj_readlines
def test_fileobj_iter
def test_fileobj_seek
def test_fileobj_link1
def test_fileobj_link2
def test_fileobj_symlink1
def test_fileobj_symlink2
def setUp
def tearDown

Public Attributes

 tar

Static Public Attributes

 tarname = bz2name
string mode = "r:"

Detailed Description

Definition at line 1708 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 82 of file test_tarfile.py.

00082 
00083     def test_fileobj_iter(self):
00084         self.tar.extract("ustar/regtype", TEMPDIR)
00085         tarinfo = self.tar.getmember("ustar/regtype")
00086         with open(os.path.join(TEMPDIR, "ustar/regtype"), "rU") as fobj1:
00087             lines1 = fobj1.readlines()
00088         fobj2 = self.tar.extractfile(tarinfo)
00089         try:
00090             lines2 = list(io.TextIOWrapper(fobj2))
00091             self.assertTrue(lines1 == lines2,
00092                          "fileobj.__iter__() failed")
00093         finally:
00094             fobj2.close()

Here is the call graph for this function:

Definition at line 157 of file test_tarfile.py.

00157 
00158     def test_fileobj_link1(self):
00159         self._test_fileobj_link("ustar/lnktype", "ustar/regtype")

Here is the call graph for this function:

Definition at line 160 of file test_tarfile.py.

00160 
00161     def test_fileobj_link2(self):
00162         self._test_fileobj_link("./ustar/linktest2/lnktype", "ustar/linktest1/regtype")

Here is the call graph for this function:

Definition at line 62 of file test_tarfile.py.

00062 
00063     def test_fileobj_readlines(self):
00064         self.tar.extract("ustar/regtype", TEMPDIR)
00065         tarinfo = self.tar.getmember("ustar/regtype")
00066         with open(os.path.join(TEMPDIR, "ustar/regtype"), "r") as fobj1:
00067             lines1 = fobj1.readlines()
00068 
00069         fobj = self.tar.extractfile(tarinfo)
00070         try:
00071             fobj2 = io.TextIOWrapper(fobj)
00072             lines2 = fobj2.readlines()
00073             self.assertTrue(lines1 == lines2,
00074                     "fileobj.readlines() failed")
00075             self.assertTrue(len(lines2) == 114,
00076                     "fileobj.readlines() failed")
00077             self.assertTrue(lines2[83] ==
00078                     "I will gladly admit that Python is not the fastest running scripting language.\n",
00079                     "fileobj.readlines() failed")
00080         finally:
00081             fobj.close()

Here is the call graph for this function:

Definition at line 52 of file test_tarfile.py.

00052 
00053     def test_fileobj_regular_file(self):
00054         tarinfo = self.tar.getmember("ustar/regtype")
00055         fobj = self.tar.extractfile(tarinfo)
00056         try:
00057             data = fobj.read()
00058             self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
00059                     "regular file extraction failed")
00060         finally:
00061             fobj.close()

Here is the call graph for this function:

Definition at line 95 of file test_tarfile.py.

00095 
00096     def test_fileobj_seek(self):
00097         self.tar.extract("ustar/regtype", TEMPDIR)
00098         with open(os.path.join(TEMPDIR, "ustar/regtype"), "rb") as fobj:
00099             data = fobj.read()
00100 
00101         tarinfo = self.tar.getmember("ustar/regtype")
00102         fobj = self.tar.extractfile(tarinfo)
00103 
00104         text = fobj.read()
00105         fobj.seek(0)
00106         self.assertEqual(0, fobj.tell(),
00107                      "seek() to file's start failed")
00108         fobj.seek(2048, 0)
00109         self.assertEqual(2048, fobj.tell(),
00110                      "seek() to absolute position failed")
00111         fobj.seek(-1024, 1)
00112         self.assertEqual(1024, fobj.tell(),
00113                      "seek() to negative relative position failed")
00114         fobj.seek(1024, 1)
00115         self.assertEqual(2048, fobj.tell(),
00116                      "seek() to positive relative position failed")
00117         s = fobj.read(10)
00118         self.assertTrue(s == data[2048:2058],
00119                      "read() after seek failed")
00120         fobj.seek(0, 2)
00121         self.assertEqual(tarinfo.size, fobj.tell(),
00122                      "seek() to file's end failed")
00123         self.assertTrue(fobj.read() == b"",
00124                      "read() at file's end did not return empty string")
00125         fobj.seek(-tarinfo.size, 2)
00126         self.assertEqual(0, fobj.tell(),
00127                      "relative seek() to file's end failed")
00128         fobj.seek(512)
00129         s1 = fobj.readlines()
00130         fobj.seek(512)
00131         s2 = fobj.readlines()
00132         self.assertTrue(s1 == s2,
00133                      "readlines() after seek failed")
00134         fobj.seek(0)
00135         self.assertEqual(len(fobj.readline()), fobj.tell(),
00136                      "tell() after readline() failed")
00137         fobj.seek(512)
00138         self.assertTrue(len(fobj.readline()) + 512 == fobj.tell(),
00139                      "tell() after seek() and readline() failed")
00140         fobj.seek(0)
00141         line = fobj.readline()
00142         self.assertEqual(fobj.read(), data[len(line):],
00143                      "read() after readline() failed")
00144         fobj.close()

Here is the call graph for this function:

Definition at line 163 of file test_tarfile.py.

00163 
00164     def test_fileobj_symlink1(self):
00165         self._test_fileobj_link("ustar/symtype", "ustar/regtype")

Here is the call graph for this function:

Definition at line 166 of file test_tarfile.py.

00166 
00167     def test_fileobj_symlink2(self):
00168         self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype")
00169 

Here is the call graph for this function:


Member Data Documentation

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

Reimplemented in test.test_tarfile.MemberReadTest.

Definition at line 44 of file test_tarfile.py.

Reimplemented from test.test_tarfile.ReadTest.

Definition at line 1709 of file test_tarfile.py.


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