Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_zipimport.BadFileZipImportTestCase Class Reference

List of all members.

Public Member Functions

def assertZipFailure
def testNoFile
def testEmptyFilename
def testBadArgs
def testFilenameTooLong
def testEmptyFile
def testFileUnreadable
def testNotZipFile

Private Member Functions

def _testBogusZipFile

Detailed Description

Definition at line 400 of file test_zipimport.py.


Member Function Documentation

Definition at line 443 of file test_zipimport.py.

00443 
00444     def _testBogusZipFile(self):
00445         support.unlink(TESTMOD)
00446         fp = open(TESTMOD, 'w+')
00447         fp.write(struct.pack('=I', 0x06054B50))
00448         fp.write('a' * 18)
00449         fp.close()
00450         z = zipimport.zipimporter(TESTMOD)
00451 
00452         try:
00453             self.assertRaises(TypeError, z.find_module, None)
00454             self.assertRaises(TypeError, z.load_module, None)
00455             self.assertRaises(TypeError, z.is_package, None)
00456             self.assertRaises(TypeError, z.get_code, None)
00457             self.assertRaises(TypeError, z.get_data, None)
00458             self.assertRaises(TypeError, z.get_source, None)
00459 
00460             error = zipimport.ZipImportError
00461             self.assertEqual(z.find_module('abc'), None)
00462 
00463             self.assertRaises(error, z.load_module, 'abc')
00464             self.assertRaises(error, z.get_code, 'abc')
00465             self.assertRaises(IOError, z.get_data, 'abc')
00466             self.assertRaises(error, z.get_source, 'abc')
00467             self.assertRaises(error, z.is_package, 'abc')
00468         finally:
00469             zipimport._zip_directory_cache.clear()
00470 

Here is the call graph for this function:

Definition at line 401 of file test_zipimport.py.

00401 
00402     def assertZipFailure(self, filename):
00403         self.assertRaises(zipimport.ZipImportError,
00404                           zipimport.zipimporter, filename)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 411 of file test_zipimport.py.

00411 
00412     def testBadArgs(self):
00413         self.assertRaises(TypeError, zipimport.zipimporter, None)
00414         self.assertRaises(TypeError, zipimport.zipimporter, TESTMOD, kwd=None)

Here is the call graph for this function:

Definition at line 418 of file test_zipimport.py.

00418 
00419     def testEmptyFile(self):
00420         support.unlink(TESTMOD)
00421         open(TESTMOD, 'w+').close()
00422         self.assertZipFailure(TESTMOD)

Here is the call graph for this function:

Definition at line 408 of file test_zipimport.py.

00408 
00409     def testEmptyFilename(self):
00410         self.assertZipFailure('')

Here is the call graph for this function:

Definition at line 415 of file test_zipimport.py.

00415 
00416     def testFilenameTooLong(self):
00417         self.assertZipFailure('A' * 33000)

Here is the call graph for this function:

Definition at line 423 of file test_zipimport.py.

00423 
00424     def testFileUnreadable(self):
00425         support.unlink(TESTMOD)
00426         fd = os.open(TESTMOD, os.O_CREAT, 000)
00427         try:
00428             os.close(fd)
00429             self.assertZipFailure(TESTMOD)
00430         finally:
00431             # If we leave "the read-only bit" set on Windows, nothing can
00432             # delete TESTMOD, and later tests suffer bogus failures.
00433             os.chmod(TESTMOD, 0o666)
00434             support.unlink(TESTMOD)

Here is the call graph for this function:

Definition at line 405 of file test_zipimport.py.

00405 
00406     def testNoFile(self):
00407         self.assertZipFailure('AdfjdkFJKDFJjdklfjs')

Here is the call graph for this function:

Definition at line 435 of file test_zipimport.py.

00435 
00436     def testNotZipFile(self):
00437         support.unlink(TESTMOD)
00438         fp = open(TESTMOD, 'w+')
00439         fp.write('a' * 22)
00440         fp.close()
00441         self.assertZipFailure(TESTMOD)

Here is the call graph for this function:


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