Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.source.test_abc_loader.RegeneratedBytecodeTests Class Reference

List of all members.

Public Member Functions

def test_different_magic
def test_old_mtime

Detailed Description

Test that bytecode is regenerated as expected.

Definition at line 425 of file test_abc_loader.py.


Member Function Documentation

Definition at line 430 of file test_abc_loader.py.

00430 
00431     def test_different_magic(self):
00432         # A different magic number should lead to new bytecode.
00433         name = 'mod'
00434         bad_magic = b'\x00\x00\x00\x00'
00435         assert bad_magic != imp.get_magic()
00436         mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')},
00437                                 {name: {'path': os.path.join('path', 'to',
00438                                                     'mod.bytecode'),
00439                                         'magic': bad_magic}})
00440         with util.uncache(name):
00441             mock.load_module(name)
00442         self.assertTrue(name in mock.module_bytecode)
00443         magic = mock.module_bytecode[name][:4]
00444         self.assertEqual(magic, imp.get_magic())

Here is the call graph for this function:

Definition at line 446 of file test_abc_loader.py.

00446 
00447     def test_old_mtime(self):
00448         # Bytecode with an older mtime should be regenerated.
00449         name = 'mod'
00450         old_mtime = PyPycLoaderMock.default_mtime - 1
00451         mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')},
00452                 {name: {'path': 'path/to/mod.bytecode', 'mtime': old_mtime}})
00453         with util.uncache(name):
00454             mock.load_module(name)
00455         self.assertTrue(name in mock.module_bytecode)
00456         mtime = importlib._r_long(mock.module_bytecode[name][4:8])
00457         self.assertEqual(mtime, PyPycLoaderMock.default_mtime)
00458 

Here is the call graph for this function:


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