from decimal import * Objects = [Context, Decimal, dict, list, int, float, None, True, False, 1, 2] def gen_unary(): for x in Objects: yield x def gen_binary(): for x in Objects: for y in Objects: yield x, y def testit(obj, attr, args, reclevel): ex = result = None try: result = getattr(obj, attr)(*args) except Exception as e: ex = e.__class__ if ex is None and reclevel == 0: test_context_api(result, reclevel=1) def test_context_api(obj=Context, reclevel=0): for attr in dir(obj): testit(obj, attr, (), reclevel) for x in gen_unary(): testit(obj, attr, (x,), reclevel) for x, y in gen_binary(): testit(obj, attr, (x, y), reclevel) test_context_api()