diff tests/test.py @ 8:15c7171941ea

more stubbing for tests
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 28 Feb 2012 13:50:28 -0800
parents 232e67cac00c
children 9879140a2026
line wrap: on
line diff
--- a/tests/test.py	Tue Feb 28 10:30:44 2012 -0800
+++ b/tests/test.py	Tue Feb 28 13:50:28 2012 -0800
@@ -6,9 +6,11 @@
 
 import doctest
 import os
+import shutil
 import sys
+import tempfile
 from optparse import OptionParser
-
+from paste.fixture import TestApp
 
 def run_tests(raise_on_error=False, report_first=False):
 
@@ -28,12 +30,20 @@
 
     # run the tests
     for test in tests:
+
+        # make a temporary directory
+        tmpdir = tempfile.mkdtemp()
+        doctest_args['extraglobs']['directory'] = tmpdir
+
         try:
             results[test] = doctest.testfile(test, **doctest_args)
         except doctest.DocTestFailure, failure:
             raise
         except doctest.UnexpectedException, failure:
             raise failure.exc_info[0], failure.exc_info[1], failure.exc_info[2]
+        finally:
+            if os.path.exists(tmpdir):
+                shutil.rmtree(tmpdir)
 
     return results