Commits

Maciej Fijalkowski committed 364b24d

Kill the ability to load only .pyc files. Put those tests as specific to 2.6

  • Participants
  • Parent commits 01c5a78

Comments (0)

Files changed (2)

     """
     fname = str(fname)
     if fname.endswith('.pyc'):
-        f = open(fname)
-        magic = f.read(4)
-        f.read(4) # timestamp
-        if magic != imp.get_magic():
-            f.close()
-            code = compile(open(fname[:-1]).read(), fname, 'exec')
-        else:
-            code = marshal.loads(f.read())
-            f.close()
-            assert isinstance(code, types.CodeType)
+        code = compile(open(fname[:-1]).read(), fname, 'exec')
     elif fname.endswith('.py'):
         code = compile(open(fname).read(), fname, 'exec')
     else:

test/test_module.py

 
 import py
 from module_finder import gather_all_code_objs
-import re
+import re, sys
 
-def test_gather_code():
-    fname = py.path.local(__file__).join('..', 'xre.pyc')
-    codes = gather_all_code_objs(fname)
-    assert len(codes) == 21
-    assert sorted(codes.keys()) == [102, 134, 139, 144, 153, 164, 169, 181, 188, 192, 197, 206, 229, 251, 266, 271, 277, 285, 293, 294, 308]
+def setup_module(mod):
+    if sys.version_info[:2] != (2.6):
+        py.test.skip("Specific python 2.6 tests")
 
 def test_gather_code_py():
     fname = re.__file__
-    if fname.endswith('.pyc'):
-        fname = fname[:-1]
     codes = gather_all_code_objs(fname)
     assert len(codes) == 21
     assert sorted(codes.keys()) == [102, 134, 139, 144, 153, 164, 169, 181, 188, 192, 197, 206, 229, 251, 266, 271, 277, 285, 293, 294, 308]
 
 def test_load_code():
-    fname = py.path.local(__file__).join('..', 'xre.pyc')
+    fname = re.__file__
     code = gather_all_code_objs(fname)[144]
     assert code.co_name == 'sub'
     assert code.co_filename == '/usr/lib/python2.6/re.py'
     assert code.co_firstlineno == 144
-
-def test_ast():
-    pass