fixed so test suite can be run in test dir
authorandy
Wed, 10 Sep 2008 22:39:57 +0000
changeset 2978 1e68f6a61dfe
parent 2977 beca8d75f400
child 2979 03d7d7c69550
fixed so test suite can be run in test dir
tests/00readme.txt
tests/runAll.py
tools/docco/graphdocpy.py
--- a/tests/00readme.txt	Wed Sep 10 17:57:51 2008 +0000
+++ b/tests/00readme.txt	Wed Sep 10 22:39:57 2008 +0000
@@ -3,12 +3,10 @@
 All test scripts should be named like test_*.py, where * describes which
 parts of the ReportLab toolkit are being tested (see sample test scripts).
 
-The test scripts are expected to make use of the PyUnit test environment
-named unittest (see pyunit.sourceforge.net). For convenience this comes
-bundled with the ReportLab toolkit in the reportlab.test subpackage.
-
-As of now, this folder has a flat structure, but it might be restructured
-in the future as the amount of tests will grow dramatically.
+Most tests can be executed individually, or all can be run with 'runAll.py'.
+Some tests are functional rather than unit-tests and do things like
+generating the manuals, which assumes that you have the normal source
+distribution layout and other directories in the correct locations.
 
 The file runAll.py begins by deleting any files with extension ".pdf" or
 ".log" in the test directory, so you can't confuse old and current
--- a/tests/runAll.py	Wed Sep 10 17:57:51 2008 +0000
+++ b/tests/runAll.py	Wed Sep 10 22:39:57 2008 +0000
@@ -5,7 +5,18 @@
 """
 __version__=''' $Id$ '''
 import os, glob, sys, string, traceback, unittest
-from tests.utils import GlobDirectoryWalker, outputfile, printLocation
+
+#we need to ensure 'tests' is on the path.  It will be if you
+#run 'setup.py tests', but won't be if you CD into the tests
+#directory and run this directly
+try:
+    from tests.utils import GlobDirectoryWalker, outputfile, printLocation
+except ImportError:
+    directoryAboveMe = os.path.dirname(os.getcwd())
+    sys.path.insert(0, directoryAboveMe)
+    from tests.utils import GlobDirectoryWalker, outputfile, printLocation
+    
+    
 
 def makeSuite(folder, exclude=[],nonImportable=[],pattern='test_*.py'):
     "Build a test suite of all available test files."
--- a/tools/docco/graphdocpy.py	Wed Sep 10 17:57:51 2008 +0000
+++ b/tools/docco/graphdocpy.py	Wed Sep 10 22:39:57 2008 +0000
@@ -957,7 +957,12 @@
 
     #if doing the usual, put a copy in docs
     if builder.outPath=='reportlab.graphics.pdf':
-        import shutil, tools
+        import shutil
+        try:
+            import tools
+        except ImportError: #probably running in tools/docco
+            sys.path.insert(0, os.path.dirname(os.path.dirname(os.getcwd())))
+            import tools
         topDir=tools.__path__[0]
         if not os.path.isabs(topDir): topDir=os.path.abspath(topDir)
         topDir=os.path.dirname(topDir)