def check_limit(prefix, repeated, mode='single'):
    expect_ok = (prefix + (repeated * success_depth))
    compile(expect_ok, '<test>', mode)
    for depth in (fail_depth, crash_depth):
        broken = (prefix + (repeated * depth))
        details = 'Compiling ({!r} + {!r} * {})'.format(prefix, repeated, depth)
        with self.assertRaises(RecursionError, msg=details):
            compile(broken, '<test>', mode)
def check_limit(prefix, repeated, mode='single'):
    expect_ok = (prefix + (repeated * success_depth))
    compile(expect_ok, '<test>', mode)
    for depth in (fail_depth, crash_depth):
        broken = (prefix + (repeated * depth))
        details = 'Compiling ({!r} + {!r} * {})'.format(prefix, repeated, depth)
        with self.assertRaises(RecursionError, msg=details):
            compile(broken, '<test>', mode)