def testsource(module, name):
    module = _normalize_module(module)
    tests = DocTestFinder().find(module)
    test = [t for t in tests if t.name == name]
    if not test:
        raise ValueError(name, "not found in tests")
    test = test[0]
    testsrc = script_from_examples(test.docstring)
    return testsrc
Extract the test sources from a doctest docstring as a script.
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/test/_doctest.py/testsource