[Python-checkins] r52567 - sandbox/trunk/import_in_py/test_importer.py
brett.cannon
python-checkins at python.org
Wed Nov 1 00:00:36 CET 2006
Author: brett.cannon
Date: Wed Nov 1 00:00:36 2006
New Revision: 52567
Modified:
sandbox/trunk/import_in_py/test_importer.py
Log:
Flesh out two tests.
Modified: sandbox/trunk/import_in_py/test_importer.py
==============================================================================
--- sandbox/trunk/import_in_py/test_importer.py (original)
+++ sandbox/trunk/import_in_py/test_importer.py Wed Nov 1 00:00:36 2006
@@ -281,14 +281,23 @@
# Should be able to read a file.
source = self.loader.read_data(self.source_path, False)
self.failUnlessEqual(source, self.source)
- # XXX Binary reads.
+ test_text = '1\r\n2'
+ try:
+ with open(test_support.TESTFN, 'wb') as test_file:
+ test_file.write(test_text)
+ result = self.loader.read_data(test_support.TESTFN, binary=True)
+ self.failUnlessEqual(result, test_text)
+ result = self.loader.read_data(test_support.TESTFN, binary=False)
+ self.failUnlessEqual(result, test_text.replace('\r', ''))
+ finally:
+ os.remove(test_support.TESTFN)
def test_write_data(self):
# Should be able to write a file.
self.loader.write_data(self.source, self.source_path, False)
read_source = self.loader.read_data(self.source_path, False)
self.failUnlessEqual(read_source, self.source)
- # XXX Binary writes.
+ # XXX How to test data written with 'b'?
class PyPycHandlerSupportingMethodTests(PyPycFileHelper):
@@ -323,7 +332,14 @@
# Split up data from .pyc file for the magic number, timestamp,
# and bytecode.
pass
- # XXX
+ # XXX Can't fully test until unmarshaling longs is available.
+ with open(self.bytecode_path, 'rb') as bytecode_file:
+ pyc = bytecode_file.read()
+ magic, timestamp, bytecode = self.handler.parse_pyc(pyc)
+ code = marshal.loads(bytecode)
+ module = imp.new_module(self.module)
+ exec code in module.__dict__
+ self.verify_module(module)
def test_check_magic(self):
# Compare a number against the magic number.
More information about the Python-checkins
mailing list