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()
c.importCommands.flattenOutline(filename)
# 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
file.write(text)
file.close()
# g.es(filename)
failures, tests = doctest.testfile(filename, module_relative = False)
os.remove(filename)

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