def assertBlock(self, python, java): self.maxDiff = None dump = False py_block = PyBlock(parent=PyModule('test', 'test.py')) if python: python = adjust(python) code = compile(python, '<test>', 'exec') py_block.extract(code, debug=dump) java_code = py_block.transpile() out = BytesIO() constant_pool = ConstantPool() java_code.resolve(constant_pool) constant_pool.add(Utf8('test')) constant_pool.add(Utf8('Code')) constant_pool.add(Utf8('LineNumberTable')) writer = ClassFileWriter(out, constant_pool) java_code.write(writer) debug = StringIO() reader = ClassFileReader(BytesIO(out.getbuffer()), constant_pool, debug=debug) JavaCode.read(reader, dump=0) if dump: print(debug.getvalue()) java = adjust(java) self.assertEqual(debug.getvalue(), java[1:])