import pytest import dis from testutils import get_co, get_bytecode from equip import BytecodeObject from equip.bytecode.utils import show_bytecode import equip.utils.log as logutils from equip.utils.log import logger logutils.enableLogger(to_file='./equip.log') from equip.analysis import ControlFlow, BasicBlock, CallGraph, DefUse SIMPLE_PROGRAM = """ import random import sys def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): while True: ok = raw_input(prompt) if ok in ('y', 'ye', 'yes'): return ask_ok(ok) if ok in ('n', 'no', 'nop', 'nope'): some_value(some_value(some_value(some_value(1)))) return False retries = retries - 1 if retries < 0: raise IOError('refusenik user') print "Never reached" print complaint
import pytest from testutils import get_co, get_bytecode from equip import BytecodeObject from equip.bytecode.utils import show_bytecode import equip.utils.log as logutils from equip.utils.log import logger logutils.enableLogger(to_file='./equip.log') from equip.analysis import ControlFlow, BasicBlock SIMPLE_PROGRAM = """ import random import sys a = lambda x, y: x + (y if foo == 'bar' else x) def some_value(i): if (i % 2) == 0: print "even", elif foobar: print "whatever" else: print "odd", for n in range(2, 10): for x in range(2, n): if n % x == 0: print n, 'equals', x, '*', n/x break