[PATCH 1 of 3] tests: remove temp doctest file when finished running it

Idan Kamara idankk86 at gmail.com
Thu Oct 13 10:56:09 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1318521275 -7200
# Node ID 53e6242edf135ede8a8743e2d9a3c3d83960513e
# Parent  dac2edce4e4a7eb63ff2c1bb6ab2289c0bcec9e5
tests: remove temp doctest file when finished running it

diff --git a/tests/heredoctest.py b/tests/heredoctest.py
--- a/tests/heredoctest.py
+++ b/tests/heredoctest.py
@@ -2,8 +2,12 @@
 
 if __name__ == "__main__":
     fd, name = tempfile.mkstemp(suffix='hg-tst')
-    os.write(fd, sys.stdin.read())
-    os.close(fd)
-    failures, _ = doctest.testfile(name, module_relative=False)
-    if failures:
-        sys.exit(1)
+
+    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)


More information about the Mercurial-devel mailing list