node @button dt, run doctest on current tree:

import doctest
import os

# create temporary file and write this node subtree to it
file, filename = g.create_temp_file()
# the file is now created and closed

# prepare content for testing
# strip trailing whitespace, an annoying source of doctest failures
text = open(filename).readlines()
text = [line.strip() for line in text]
text = "\n".join(text)

# run doctest on temporary file
failures, tests = doctest.testfile(filename, module_relative = False)

# report summary of results in Leo
if failures == 0:"%s tests run successfully" % tests, color="blue")
if failures == 1:"There was one failure in %s tests" % tests, color="red")
if failures > 1:"%s failures in %s tests" % (failures, tests), color="red")