def _test():
    class Original:
        def __init__(self):
            self.sum = 0
        def add(self, n):
            self._add(n)
        def _add(self, n):
            self.sum = self.sum + n
        def total(self):
            return self.sum
    o = Original()
    b = Bastion(o)
    testcode = """if 1:
    b.add(81)
    b.add(18)
    print "b.total() =", b.total()
    try:
        print "b.sum =", b.sum,
    except:
        print "inaccessible"
    else:
        print "accessible"
    try:
        print "b._add =", b._add,
    except:
        print "inaccessible"
    else:
        print "accessible"
    try:
        print "b._get_.func_defaults =", map(type, b._get_.func_defaults),
    except:
        print "inaccessible"
    else:
        print "accessible"
    \n"""
    exec testcode
    print '='*20, "Using rexec:", '='*20
    import rexec
    r = rexec.RExec()
    m = r.add_module('__main__')
    m.b = b
    r.r_exec(testcode)
Test the Bastion() function.
dataset/ETHPy150Open ctxis/canape/CANAPE.Scripting/Lib/Bastion.py/_test