[Zope3-checkins] SVN: zope.testing/trunk/ Fix testrunner-wo-source.txt and testrunner-errors.txt to run with a read-only source tree.

Brian Sutherland jinty at web.de
Wed Mar 7 19:58:15 EST 2007


Log message for revision 73046:
  Fix testrunner-wo-source.txt and testrunner-errors.txt to run with a read-only source tree.

Changed:
  U   zope.testing/trunk/CHANGES.txt
  U   zope.testing/trunk/src/zope/testing/testrunner-errors.txt
  U   zope.testing/trunk/src/zope/testing/testrunner-wo-source.txt

-=-
Modified: zope.testing/trunk/CHANGES.txt
===================================================================
--- zope.testing/trunk/CHANGES.txt	2007-03-08 00:11:01 UTC (rev 73045)
+++ zope.testing/trunk/CHANGES.txt	2007-03-08 00:58:14 UTC (rev 73046)
@@ -1,6 +1,12 @@
 zope.testing Changelog
 **********************
 
+????
+====
+
+- Fix testrunner-wo-source.txt and testrunner-errors.txt to run with a
+  read-only source tree.
+
 3.0 (2006/09/20)
 ================
 

Modified: zope.testing/trunk/src/zope/testing/testrunner-errors.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2007-03-08 00:11:01 UTC (rev 73045)
+++ zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2007-03-08 00:58:14 UTC (rev 73046)
@@ -1,10 +1,22 @@
 Errors and Failures
 ===================
 
-Let's look at tests that have errors and failures:
+Let's look at tests that have errors and failures, first we need to make a
+temporary copy of the entire testing dirctory (except .svn files which may
+be read only):
 
-    >>> import os.path, sys
-    >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
+    >>> import os.path, sys, tempfile, shutil
+    >>> tmpdir = tempfile.mkdtemp()
+    >>> directory_with_tests = os.path.join(tmpdir, 'testrunner-ex')
+    >>> source = os.path.join(this_directory, 'testrunner-ex')
+    >>> n = len(source) + 1
+    >>> for root, dirs, files in os.walk(source):
+    ...     dirs[:] = [d for d in dirs if d != ".svn"] # prune cruft
+    ...     os.mkdir(os.path.join(directory_with_tests, root[n:]))
+    ...     for f in files:
+    ...         shutil.copy(os.path.join(root, f),
+    ...                     os.path.join(directory_with_tests, root[n:], f))
+    
     >>> from zope.testing import testrunner
     >>> defaults = [
     ...     '--path', directory_with_tests,
@@ -794,6 +806,6 @@
       sample2.sample23.sampletests_i
     True
 
-And remove the file with bad syntax:
+And remove the temporary directory:
 
-    >>> os.remove(badsyntax_path)
+    >>> shutil.rmtree(tmpdir)

Modified: zope.testing/trunk/src/zope/testing/testrunner-wo-source.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-wo-source.txt	2007-03-08 00:11:01 UTC (rev 73045)
+++ zope.testing/trunk/src/zope/testing/testrunner-wo-source.txt	2007-03-08 00:58:14 UTC (rev 73046)
@@ -9,11 +9,11 @@
 this.  Because we're going to delete its .py files, we want to work
 in a copy of that:
 
-    >>> import os.path, shutil, sys
-    >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
+    >>> import os.path, shutil, sys, tempfile
+    >>> directory_with_tests = tempfile.mkdtemp()
 
     >>> NEWNAME = "unlikely_package_name"
-    >>> src = os.path.join(directory_with_tests, 'usecompiled')
+    >>> src = os.path.join(this_directory, 'testrunner-ex', 'usecompiled')
     >>> os.path.isdir(src)
     True
     >>> dst = os.path.join(directory_with_tests, NEWNAME)
@@ -33,7 +33,6 @@
 
 Now run the tests in the copy:
 
-
     >>> from zope.testing import testrunner
 
     >>> mydefaults = [
@@ -85,6 +84,6 @@
       Ran 4 tests with 0 failures and 0 errors in N.NNN seconds.
     False
 
-Remove the copy:
+Remove the temporary directory:
 
-    >>> shutil.rmtree(dst)
+    >>> shutil.rmtree(directory_with_tests)



More information about the Zope3-Checkins mailing list