Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
test.test_tarfile.AppendTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_non_existing
def test_empty
def test_empty_fileobj
def test_fileobj
def test_existing
def test_append_gz
def test_append_bz2
def test_null
def test_incomplete
def test_premature_eof
def test_trailing_garbage
def test_invalid

Public Attributes

 tarname

Private Member Functions

def _add_testfile
def _create_testtar
def _test
def _test_error

Detailed Description

Definition at line 1425 of file test_tarfile.py.


Member Function Documentation

def test.test_tarfile.AppendTest._add_testfile (   self,
  fileobj = None 
) [private]

Definition at line 1433 of file test_tarfile.py.

01433 
01434     def _add_testfile(self, fileobj=None):
01435         with tarfile.open(self.tarname, "a", fileobj=fileobj) as tar:
01436             tar.addfile(tarfile.TarInfo("bar"))

Here is the caller graph for this function:

def test.test_tarfile.AppendTest._create_testtar (   self,
  mode = "w:" 
) [private]

Definition at line 1437 of file test_tarfile.py.

01437 
01438     def _create_testtar(self, mode="w:"):
01439         with tarfile.open(tarname, encoding="iso8859-1") as src:
01440             t = src.getmember("ustar/regtype")
01441             t.name = "foo"
01442             f = src.extractfile(t)
01443             try:
01444                 with tarfile.open(self.tarname, mode) as tar:
01445                     tar.addfile(t, f)
01446             finally:
01447                 f.close()

Here is the caller graph for this function:

def test.test_tarfile.AppendTest._test (   self,
  names = ["bar"],
  fileobj = None 
) [private]

Definition at line 1448 of file test_tarfile.py.

01448 
01449     def _test(self, names=["bar"], fileobj=None):
01450         with tarfile.open(self.tarname, fileobj=fileobj) as tar:
01451             self.assertEqual(tar.getnames(), names)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_tarfile.AppendTest._test_error (   self,
  data 
) [private]

Definition at line 1495 of file test_tarfile.py.

01495 
01496     def _test_error(self, data):
01497         with open(self.tarname, "wb") as fobj:
01498             fobj.write(data)
01499         self.assertRaises(tarfile.ReadError, self._add_testfile)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1428 of file test_tarfile.py.

01428 
01429     def setUp(self):
01430         self.tarname = tmpname
01431         if os.path.exists(self.tarname):
01432             os.remove(self.tarname)

Here is the caller graph for this function:

Definition at line 1487 of file test_tarfile.py.

01487 
01488     def test_append_bz2(self):
01489         if bz2 is None:
01490             return
01491         self._create_testtar("w:bz2")
01492         self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, "a")

Here is the call graph for this function:

Definition at line 1481 of file test_tarfile.py.

01481 
01482     def test_append_gz(self):
01483         if gzip is None:
01484             return
01485         self._create_testtar("w:gz")
01486         self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, "a")

Here is the call graph for this function:

Definition at line 1456 of file test_tarfile.py.

01456 
01457     def test_empty(self):
01458         tarfile.open(self.tarname, "w:").close()
01459         self._add_testfile()
01460         self._test()

Here is the call graph for this function:

Definition at line 1461 of file test_tarfile.py.

01461 
01462     def test_empty_fileobj(self):
01463         fobj = io.BytesIO(b"\0" * 1024)
01464         self._add_testfile(fobj)
01465         fobj.seek(0)
01466         self._test(fileobj=fobj)

Here is the call graph for this function:

Definition at line 1476 of file test_tarfile.py.

01476 
01477     def test_existing(self):
01478         self._create_testtar()
01479         self._add_testfile()
01480         self._test(names=["foo", "bar"])

Here is the call graph for this function:

Definition at line 1467 of file test_tarfile.py.

01467 
01468     def test_fileobj(self):
01469         self._create_testtar()
01470         with open(self.tarname, "rb") as fobj:
01471             data = fobj.read()
01472         fobj = io.BytesIO(data)
01473         self._add_testfile(fobj)
01474         fobj.seek(0)
01475         self._test(names=["foo", "bar"], fileobj=fobj)

Here is the call graph for this function:

Definition at line 1503 of file test_tarfile.py.

01503 
01504     def test_incomplete(self):
01505         self._test_error(b"\0" * 13)

Here is the call graph for this function:

Definition at line 1514 of file test_tarfile.py.

01514 
01515     def test_invalid(self):
01516         self._test_error(b"a" * 512)
01517 

Here is the call graph for this function:

Definition at line 1452 of file test_tarfile.py.

01452 
01453     def test_non_existing(self):
01454         self._add_testfile()
01455         self._test()

Here is the call graph for this function:

Definition at line 1500 of file test_tarfile.py.

01500 
01501     def test_null(self):
01502         self._test_error(b"")

Here is the call graph for this function:

Definition at line 1506 of file test_tarfile.py.

01506 
01507     def test_premature_eof(self):
01508         data = tarfile.TarInfo("foo").tobuf()
01509         self._test_error(data)

Here is the call graph for this function:

Definition at line 1510 of file test_tarfile.py.

01510 
01511     def test_trailing_garbage(self):
01512         data = tarfile.TarInfo("foo").tobuf()
01513         self._test_error(data + b"\0" * 13)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1429 of file test_tarfile.py.


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