Back to index

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

List of all members.

Public Member Functions

def test_bad_pax_header
def test_iso8859_1_filename
def test_utf7_filename
def test_utf8_filename
def test_unicode_filename_error
def test_unicode_argument
def test_uname_unicode

Static Public Attributes

 format = tarfile.GNU_FORMAT

Detailed Description

Definition at line 1394 of file test_tarfile.py.


Member Function Documentation

Definition at line 1398 of file test_tarfile.py.

01398 
01399     def test_bad_pax_header(self):
01400         # Test for issue #8633. GNU tar <= 1.23 creates raw binary fields
01401         # without a hdrcharset=BINARY header.
01402         for encoding, name in (("utf8", "pax/bad-pax-\udce4\udcf6\udcfc"),
01403                 ("iso8859-1", "pax/bad-pax-\xe4\xf6\xfc"),):
01404             with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
01405                 try:
01406                     t = tar.getmember(name)
01407                 except KeyError:
01408                     self.fail("unable to read bad GNU tar pax header")
01409 

Here is the call graph for this function:

Definition at line 1315 of file test_tarfile.py.

01315 
01316     def test_iso8859_1_filename(self):
01317         self._test_unicode_filename("iso8859-1")

Here is the call graph for this function:

Definition at line 1367 of file test_tarfile.py.

01367 
01368     def test_uname_unicode(self):
01369         t = tarfile.TarInfo("foo")
01370         t.uname = "\xe4\xf6\xfc"
01371         t.gname = "\xe4\xf6\xfc"
01372 
01373         tar = tarfile.open(tmpname, mode="w", format=self.format, encoding="iso8859-1")
01374         try:
01375             tar.addfile(t)
01376         finally:
01377             tar.close()
01378 
01379         tar = tarfile.open(tmpname, encoding="iso8859-1")
01380         try:
01381             t = tar.getmember("foo")
01382             self.assertEqual(t.uname, "\xe4\xf6\xfc")
01383             self.assertEqual(t.gname, "\xe4\xf6\xfc")
01384 
01385             if self.format != tarfile.PAX_FORMAT:
01386                 tar.close()
01387                 tar = tarfile.open(tmpname, encoding="ascii")
01388                 t = tar.getmember("foo")
01389                 self.assertEqual(t.uname, "\udce4\udcf6\udcfc")
01390                 self.assertEqual(t.gname, "\udce4\udcf6\udcfc")
01391         finally:
01392             tar.close()
01393 

Here is the call graph for this function:

Definition at line 1356 of file test_tarfile.py.

01356 
01357     def test_unicode_argument(self):
01358         tar = tarfile.open(tarname, "r", encoding="iso8859-1", errors="strict")
01359         try:
01360             for t in tar:
01361                 self.assertTrue(type(t.name) is str)
01362                 self.assertTrue(type(t.linkname) is str)
01363                 self.assertTrue(type(t.uname) is str)
01364                 self.assertTrue(type(t.gname) is str)
01365         finally:
01366             tar.close()

Here is the call graph for this function:

Definition at line 1338 of file test_tarfile.py.

01338 
01339     def test_unicode_filename_error(self):
01340         if self.format == tarfile.PAX_FORMAT:
01341             # PAX_FORMAT ignores encoding in write mode.
01342             return
01343 
01344         tar = tarfile.open(tmpname, "w", format=self.format, encoding="ascii", errors="strict")
01345         try:
01346             tarinfo = tarfile.TarInfo()
01347 
01348             tarinfo.name = "\xe4\xf6\xfc"
01349             self.assertRaises(UnicodeError, tar.addfile, tarinfo)
01350 
01351             tarinfo.name = "foo"
01352             tarinfo.uname = "\xe4\xf6\xfc"
01353             self.assertRaises(UnicodeError, tar.addfile, tarinfo)
01354         finally:
01355             tar.close()

Here is the call graph for this function:

Definition at line 1318 of file test_tarfile.py.

01318 
01319     def test_utf7_filename(self):
01320         self._test_unicode_filename("utf7")

Here is the call graph for this function:

Definition at line 1321 of file test_tarfile.py.

01321 
01322     def test_utf8_filename(self):
01323         self._test_unicode_filename("utf8")

Here is the call graph for this function:


Member Data Documentation

Reimplemented from test.test_tarfile.UstarUnicodeTest.

Definition at line 1396 of file test_tarfile.py.


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