Exemplo n.º 1
0
 def verify_bytecode(self, mock, name):
     assert name in mock.module_paths
     self.assertIn(name, mock.module_bytecode)
     magic = mock.module_bytecode[name][:4]
     self.assertEqual(magic, imp.get_magic())
     mtime = importlib_full._r_long(mock.module_bytecode[name][4:8])
     self.assertEqual(mtime, 1)
     bc = mock.module_bytecode[name][8:]
     self.assertEqual(bc, mock.compile_bc(name))
Exemplo n.º 2
0
 def test_old_mtime(self):
     # Bytecode with an older mtime should be regenerated.
     name = u'mod'
     old_mtime = PyPycLoaderMock.default_mtime - 1
     mock = PyPycLoaderMock({name: os.path.join(u'path', u'to', u'mod')},
             {name: {u'path': u'path/to/mod.bytecode', u'mtime': old_mtime}})
     with util.uncache(name):
         mock.load_module(name)
     self.assertTrue(name in mock.module_bytecode)
     mtime = importlib_full._r_long(mock.module_bytecode[name][4:8])
     self.assertEqual(mtime, PyPycLoaderMock.default_mtime)