Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_no_password
def test_bad_password
def test_good_password
def test_unicode_password

Public Attributes

 zip
 zip2

Static Public Attributes

tuple data
tuple data2
string plain = 'zipfile.py encryption test'
string plain2 = '\x00'

Detailed Description

Check that ZIP decryption works. Since the library does not
support encryption at the moment, we use a pre-generated encrypted
ZIP file.

Definition at line 1061 of file test_zipfile.py.


Member Function Documentation

Definition at line 1087 of file test_zipfile.py.

01087 
01088     def setUp(self):
01089         with open(TESTFN, "wb") as fp:
01090             fp.write(self.data)
01091         self.zip = zipfile.ZipFile(TESTFN, "r")
01092         with open(TESTFN2, "wb") as fp:
01093             fp.write(self.data2)
01094         self.zip2 = zipfile.ZipFile(TESTFN2, "r")

Here is the caller graph for this function:

Definition at line 1095 of file test_zipfile.py.

01095 
01096     def tearDown(self):
01097         self.zip.close()
01098         os.unlink(TESTFN)
01099         self.zip2.close()
01100         os.unlink(TESTFN2)

Here is the caller graph for this function:

Definition at line 1107 of file test_zipfile.py.

01107 
01108     def test_bad_password(self):
01109         self.zip.setpassword(b"perl")
01110         self.assertRaises(RuntimeError, self.zip.read, "test.txt")
01111         self.zip2.setpassword(b"perl")
01112         self.assertRaises(RuntimeError, self.zip2.read, "zero")

Here is the call graph for this function:

Definition at line 1114 of file test_zipfile.py.

01114 
01115     def test_good_password(self):
01116         self.zip.setpassword(b"python")
01117         self.assertEqual(self.zip.read("test.txt"), self.plain)
01118         self.zip2.setpassword(b"12345")
01119         self.assertEqual(self.zip2.read("zero"), self.plain2)

Here is the call graph for this function:

Definition at line 1101 of file test_zipfile.py.

01101 
01102     def test_no_password(self):
01103         # Reading the encrypted file without password
01104         # must generate a RunTime exception
01105         self.assertRaises(RuntimeError, self.zip.read, "test.txt")
01106         self.assertRaises(RuntimeError, self.zip2.read, "zero")

Here is the call graph for this function:

Definition at line 1120 of file test_zipfile.py.

01120 
01121     def test_unicode_password(self):
01122         self.assertRaises(TypeError, self.zip.setpassword, "unicode")
01123         self.assertRaises(TypeError, self.zip.read, "test.txt", "python")
01124         self.assertRaises(TypeError, self.zip.open, "test.txt", pwd="python")
01125         self.assertRaises(TypeError, self.zip.extract, "test.txt", pwd="python")
01126 

Here is the call graph for this function:


Member Data Documentation

Initial value:
(
    b'PK\x03\x04\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00\x1a\x00'
    b'\x00\x00\x08\x00\x00\x00test.txt\xfa\x10\xa0gly|\xfa-\xc5\xc0=\xf9y'
    b'\x18\xe0\xa8r\xb3Z}Lg\xbc\xae\xf9|\x9b\x19\xe4\x8b\xba\xbb)

Definition at line 1066 of file test_zipfile.py.

Initial value:
(
    b'PK\x03\x04\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02'
    b'\x00\x00\x04\x00\x15\x00zeroUT\t\x00\x03\xd6\x8b\x92G\xda\x8b\x92GUx\x04'
    b'\x00\xe8\x03\xe8\x03\xc7<M\xb5a\xceX\xa3Y&\x8b{oE\xd7\x9d\x8c\x98\x02\xc0'
    b'PK\x07\x08xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00PK\x01\x02\x17\x03'
    b'\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00'
    b'\x04\x00\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00ze'
    b'roUT\x05\x00\x03\xd6\x8b\x92GUx\x00\x00PK\x05\x06\x00\x00\x00\x00\x01'
    b'\x00\x01\x00?\x00\x00\x00[\x00\x00\x00\x00\x00' )

Definition at line 1074 of file test_zipfile.py.

string test.test_zipfile.DecryptionTests.plain = 'zipfile.py encryption test' [static]

Definition at line 1084 of file test_zipfile.py.

Definition at line 1085 of file test_zipfile.py.

Definition at line 1090 of file test_zipfile.py.

Definition at line 1093 of file test_zipfile.py.


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