def load_code(self, fname): try: return self.codes[fname] except KeyError: if os.path.isabs(fname): res = gather_all_code_objs(fname) else: if self.extrapath is None: raise IOError("Cannot find %s" % fname) res = gather_all_code_objs(os.path.join(self.extrapath, fname)) self.codes[fname] = res return res
def test_load_code(): py.test.skip("XXX broken, fix me") 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_gather_code_py(): py.test.skip("XXX broken, fix me") fname = re.__file__ 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]