Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
importlib.test.source.test_file_loader.SourcelessLoaderBadBytecodeTest Class Reference
Inheritance diagram for importlib.test.source.test_file_loader.SourcelessLoaderBadBytecodeTest:
Inheritance graph
[legend]
Collaboration diagram for importlib.test.source.test_file_loader.SourcelessLoaderBadBytecodeTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_empty_file
def test_partial_magic
def test_magic_only
def test_bad_magic
def test_partial_timestamp
def test_no_marshal
def test_non_code_marshal
def import_
def manipulate_bytecode

Static Public Attributes

 loader = _bootstrap._SourcelessFileLoader

Detailed Description

Definition at line 336 of file test_file_loader.py.


Member Function Documentation

def importlib.test.source.test_file_loader.BadBytecodeTest.import_ (   self,
  file,
  module_name 
) [inherited]

Definition at line 134 of file test_file_loader.py.

00134 
00135     def import_(self, file, module_name):
00136         loader = self.loader(module_name, file)
00137         module = loader.load_module(module_name)
00138         self.assertTrue(module_name in sys.modules)

Here is the call graph for this function:

Here is the caller graph for this function:

def importlib.test.source.test_file_loader.BadBytecodeTest.manipulate_bytecode (   self,
  name,
  mapping,
  manipulator,
  del_source = False 
) [inherited]
Manipulate the bytecode of a module by passing it into a callable
that returns what to use as the new bytecode.

Definition at line 140 of file test_file_loader.py.

00140 
00141                             del_source=False):
00142         """Manipulate the bytecode of a module by passing it into a callable
00143         that returns what to use as the new bytecode."""
00144         try:
00145             del sys.modules['_temp']
00146         except KeyError:
00147             pass
00148         py_compile.compile(mapping[name])
00149         if not del_source:
00150             bytecode_path = imp.cache_from_source(mapping[name])
00151         else:
00152             os.unlink(mapping[name])
00153             bytecode_path = make_legacy_pyc(mapping[name])
00154         if manipulator:
00155             with open(bytecode_path, 'rb') as file:
00156                 bc = file.read()
00157                 new_bc = manipulator(bc)
00158             with open(bytecode_path, 'wb') as file:
00159                 if new_bc is not None:
00160                     file.write(new_bc)
00161         return bytecode_path

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 360 of file test_file_loader.py.

00360 
00361     def test_bad_magic(self):
00362         def test(name, mapping, bytecode_path):
00363             with self.assertRaises(ImportError):
00364                 self.import_(bytecode_path, name)
00365 
00366         self._test_bad_magic(test, del_source=True)

Here is the call graph for this function:

Definition at line 340 of file test_file_loader.py.

00340 
00341     def test_empty_file(self):
00342         def test(name, mapping, bytecode_path):
00343             with self.assertRaises(ImportError):
00344                 self.import_(bytecode_path, name)
00345 
00346         self._test_empty_file(test, del_source=True)

Here is the call graph for this function:

Definition at line 353 of file test_file_loader.py.

00353 
00354     def test_magic_only(self):
00355         def test(name, mapping, bytecode_path):
00356             with self.assertRaises(EOFError):
00357                 self.import_(bytecode_path, name)
00358 
00359         self._test_magic_only(test, del_source=True)

Here is the call graph for this function:

Definition at line 374 of file test_file_loader.py.

00374 
00375     def test_no_marshal(self):
00376         self._test_no_marshal(del_source=True)

Here is the call graph for this function:

Definition at line 377 of file test_file_loader.py.

00377 
00378     def test_non_code_marshal(self):
00379         self._test_non_code_marshal(del_source=True)
00380 

Here is the call graph for this function:

Definition at line 347 of file test_file_loader.py.

00347 
00348     def test_partial_magic(self):
00349         def test(name, mapping, bytecode_path):
00350             with self.assertRaises(ImportError):
00351                 self.import_(bytecode_path, name)
00352         self._test_partial_magic(test, del_source=True)

Here is the call graph for this function:

Definition at line 367 of file test_file_loader.py.

00367 
00368     def test_partial_timestamp(self):
00369         def test(name, mapping, bytecode_path):
00370             with self.assertRaises(EOFError):
00371                 self.import_(bytecode_path, name)
00372 
00373         self._test_partial_timestamp(test, del_source=True)

Here is the call graph for this function:


Member Data Documentation

Definition at line 338 of file test_file_loader.py.


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