tests/heredoctest.py
author Idan Kamara <idankk86@gmail.com>
Thu, 13 Oct 2011 17:54:35 +0200
branchstable
changeset 1108 168da136346a
parent 1107 943253aadddb
child 1109 8458561f6f94
permissions -rw-r--r--
tests: remove temp doctest file when finished running it [ original upstream message ]

import doctest, tempfile, os, sys

if __name__ == "__main__":
    fd, name = tempfile.mkstemp(suffix='hg-tst')

    try:
        os.write(fd, sys.stdin.read())
        os.close(fd)
        failures, _ = doctest.testfile(name, module_relative=False)
        if failures:
            sys.exit(1)
    finally:
        os.remove(name)