'Use as a decorator: doctest a function\'s docstring as a unittest.
This version runs normal doctests, but the idea is to make it later run
ipython syntax instead.'

def __call__(self, func):

    d2u = self
    if (func.__doc__ is not None):
        func.__doc__ = ip2py(func.__doc__)
    class Tester(unittest.TestCase, ):
        def test(self):
            runner = DocTestRunner(verbose=d2u.verbose)
            map(runner.run, d2u.finder.find(func, func.__name__))
            failed = count_failures(runner)
            if failed:
                if (len(failed) > 1):
                    err = ('Invalid    number    of    test    results:' % failed)
                    raise ValueError(err)
                self.fail(('failed    doctests:    %s' % str(failed[0])))
    Tester.__name__ = func.__name__
    return Tester
