[Python-checkins] r57235 - sandbox/trunk/import_in_py/tests/test_fs_loader.py
brett.cannon
python-checkins at python.org
Tue Aug 21 05:11:54 CEST 2007
Author: brett.cannon
Date: Tue Aug 21 05:11:53 2007
New Revision: 57235
Modified:
sandbox/trunk/import_in_py/tests/test_fs_loader.py
Log:
Make sure that bad bytecode raises an exception even when viable source is
available.
Modified: sandbox/trunk/import_in_py/tests/test_fs_loader.py
==============================================================================
--- sandbox/trunk/import_in_py/tests/test_fs_loader.py (original)
+++ sandbox/trunk/import_in_py/tests/test_fs_loader.py Tue Aug 21 05:11:53 2007
@@ -269,7 +269,12 @@
def test_malformed_bytecode(self):
# Invalid bytecode triggers an exception, source or not.
- raise NotImplementedError
+ source_mtime = int(os.stat(self.py_path).st_mtime)
+ with open(self.pyc_path, 'wb') as bytecode_file:
+ bytecode_file.write(imp.get_magic())
+ bytecode_file.write(importlib._w_long(source_mtime))
+ loader = importlib._PyFileLoader(self.module_name, self.py_path, False)
+ self.assertRaises(Exception, loader.load_module, self.module_name)
class PEP302PyFileInterface(TestPyPycPackages):
More information about the Python-checkins
mailing list