reportlab-2.2: major changes to make tests run
authorrgbecker
Wed, 03 Sep 2008 16:18:43 +0000
changeset 2966 c9df63ccabdf
parent 2965 d44115b76e55
child 2967 ea62529bd1df
reportlab-2.2: major changes to make tests run
docs/genAll.py
docs/graphguide/ch1_intro.py
docs/graphguide/ch2_concepts.py
docs/graphguide/ch3_shapes.py
docs/graphguide/ch4_widgets.py
docs/graphguide/ch5_charts.py
docs/graphguide/gengraphguide.py
docs/reference/genreference.py
docs/userguide/app_demos.py
docs/userguide/ch1_intro.py
docs/userguide/ch2_graphics.py
docs/userguide/ch2a_fonts.py
docs/userguide/ch3_pdffeatures.py
docs/userguide/ch4_platypus_concepts.py
docs/userguide/ch5_paragraphs.py
docs/userguide/ch6_tables.py
docs/userguide/ch7_custom.py
docs/userguide/ch9_future.py
docs/userguide/genuserguide.py
src/reportlab/pdfgen/pycanvas.py
tests/runAll.py
tests/test_charts_textlabels.py
tests/test_docs_build.py
tests/test_docstrings.py
tests/test_extra.py
tests/test_graphics_charts.py
tests/test_graphics_images.py
tests/test_graphics_layout.py
tests/test_graphics_speed.py
tests/test_hello.py
tests/test_images.py
tests/test_invariant.py
tests/test_lib_colors.py
tests/test_lib_sequencer.py
tests/test_lib_utils.py
tests/test_lib_validators.py
tests/test_multibyte_chs.py
tests/test_multibyte_cht.py
tests/test_multibyte_jpn.py
tests/test_multibyte_kor.py
tests/test_paragraphs.py
tests/test_pdfbase_encodings.py
tests/test_pdfbase_fontembed.py
tests/test_pdfbase_pdfmetrics.py
tests/test_pdfbase_pdfutils.py
tests/test_pdfbase_postscript.py
tests/test_pdfbase_ttfonts.py
tests/test_pdfgen_callback.py
tests/test_pdfgen_general.py
tests/test_pdfgen_links.py
tests/test_pdfgen_pagemodes.py
tests/test_pdfgen_pycanvas.py
tests/test_platypus_breaking.py
tests/test_platypus_general.py
tests/test_platypus_indents.py
tests/test_platypus_leftright.py
tests/test_platypus_paragraphs.py
tests/test_platypus_paraparser.py
tests/test_platypus_pleaseturnover.py
tests/test_platypus_tables.py
tests/test_platypus_toc.py
tests/test_platypus_xref.py
tests/test_pyfiles.py
tests/test_renderSVG.py
tests/test_rl_accel.py
tests/test_source_chars.py
tests/test_table_layout.py
tests/test_tools_pythonpoint.py
tests/test_utils.py
tests/test_widgetbase_tpc.py
tests/test_widgets_grids.py
tests/unittest.py
tests/utils.py
tools/docco/graphdocpy.py
tools/pythonpoint/pythonpoint.py
tools/pythonpoint/stdparser.py
--- a/docs/genAll.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/genAll.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,20 +1,22 @@
 #!/bin/env python
 import os, sys, traceback
-def _genAll(d=None,verbose=1):
-    if not d: d = '.'
-    if not os.path.isabs(d):
-        d = os.path.normpath(os.path.join(os.getcwd(),d))
-    L = ['reference/genreference.py',
-        'userguide/genuserguide.py',
-        'graphguide/gengraphguide.py',
-        '../tools/docco/graphdocpy.py',
+def _genAll(verbose=1):
+    from tests.utils import testsFolder
+    topDir=os.path.dirname(testsFolder)
+    L = [os.path.join(topDir,f) for f in (
+            'docs/reference/genreference.py',
+            'docs/userguide/genuserguide.py',
+            'docs/graphguide/gengraphguide.py',
+            'tools/docco/graphdocpy.py',
+            )   
         ]
-    if os.path.isdir('../rl_addons'):
-        L = L + ['../rl_addons/pyRXP/docs/PyRXP_Documentation.rml']
-    elif os.path.isdir('../../rl_addons'):
-        L = L + ['../../rl_addons/pyRXP/docs/PyRXP_Documentation.rml']
+    for f in ('src/rl_addons/pyRXP/docs/PyRXP_Documentation.rml',
+            ):
+        f = os.path.join(topDir,f)
+        if os.path.isfile(f):
+            L += [f]
+            break
     for p in L:
-        os.chdir(d)
         os.chdir(os.path.dirname(p))
         if p[-4:]=='.rml':
             try:
@@ -34,4 +36,10 @@
         verbose = 0
     else:
         verbose = 1
-    _genAll(os.path.dirname(sys.argv[0]),verbose)
+    d = os.path.dirname(sys.argv[0])
+    if not d:
+        d = os.getcwd()
+    elif not os.path.isabs(d):
+        d = os.path.abspath(d)
+    sys.path.insert(0,os.path.dirname(d))
+    _genAll(verbose)
--- a/docs/graphguide/ch1_intro.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/graphguide/ch1_intro.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/graphguide/ch1_intro.py
-from reportlab.tools.docco.rl_doc_utils import *
+__version__=''' $Id$ '''
+from tools.docco.rl_doc_utils import *
 import reportlab
 
 title("Graphics Guide")
--- a/docs/graphguide/ch2_concepts.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/graphguide/ch2_concepts.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/graphguide/ch2_concepts.py
-from reportlab.tools.docco.rl_doc_utils import *
+__version__=''' $Id$ '''
+from tools.docco.rl_doc_utils import *
 
 heading1("General Concepts")
 
--- a/docs/graphguide/ch3_shapes.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/graphguide/ch3_shapes.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,7 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2009
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/graphguide/ch3_shapes.py
-
-from reportlab.tools.docco.rl_doc_utils import *
+__version__='''$Id$'''
+from tools.docco.rl_doc_utils import *
 from reportlab.graphics.shapes import *
 
 heading1("Shapes")
@@ -413,4 +412,4 @@
                        transform=mmult(translate(300,10),
                                        rotate(30)))
 d.add(thirdAxisGroup)
-draw(d, "Groups examples")
\ No newline at end of file
+draw(d, "Groups examples")
--- a/docs/graphguide/ch4_widgets.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/graphguide/ch4_widgets.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,7 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/graphguide/ch4_widgets.py
-
-from reportlab.tools.docco.rl_doc_utils import *
+__version__=''' $Id$ '''
+from tools.docco.rl_doc_utils import *
 from reportlab.graphics.shapes import *
 from reportlab.graphics.widgets import signsandsymbols
 
@@ -419,4 +418,4 @@
 pc3.slices.fontColor = colors.yellow
 d.add(pc3, 'pie3')
 
-draw(d, 'Some sample Pies')
\ No newline at end of file
+draw(d, 'Some sample Pies')
--- a/docs/graphguide/ch5_charts.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/graphguide/ch5_charts.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,7 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/graphguide/ch5_charts.py
-
-from reportlab.tools.docco.rl_doc_utils import *
+__version__=''' $Id$ '''
+from tools.docco.rl_doc_utils import *
 from reportlab.graphics.shapes import *
 
 heading1("Charts")
@@ -1226,4 +1225,4 @@
 disc("""
 This is the tool that was mentioned in the section on 'Documenting
 Widgets'.
-""")
\ No newline at end of file
+""")
--- a/docs/graphguide/gengraphguide.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/graphguide/gengraphguide.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,24 +1,27 @@
 #!/bin/env python
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/graphguide/gengraphguide.py
 __version__=''' $Id$ '''
 __doc__ = """
 This module contains the script for building the graphics guide.
 """
 def run(pagesize=None, verbose=1, outDir=None):
-    import os
-    from reportlab.tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
-    from reportlab.tools.docco import rl_doc_utils
-    from reportlab.lib.utils import open_and_read, _RL_DIR
-    if not outDir: outDir = os.path.join(_RL_DIR,'docs')
+    import sys,os
+    cwd = os.getcwd()
+    docsDir=os.path.dirname(os.path.dirname(sys.argv[0]) or cwd)
+    topDir=os.path.dirname(docsDir)
+    if not outDir: outDir=docsDir
+    G = {}
+    sys.path.insert(0,topDir)
+    from tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
+    from tools.docco import rl_doc_utils
+    exec 'from tools.docco.rl_doc_utils import *' in G, G
+    from reportlab.lib.utils import open_and_read
     destfn = os.path.join(outDir,'graphguide.pdf')
     doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)
 
     #this builds the story
     setStory()
-    G = {}
-    exec 'from reportlab.tools.docco.rl_doc_utils import *' in G, G
     doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)
     for f in (
         'ch1_intro',
--- a/docs/reference/genreference.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/reference/genreference.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,14 +8,16 @@
 """
 def run(verbose=None, outDir=None):
     import os, sys, shutil
-    from reportlab.tools.docco import yaml2pdf
-    from reportlab.lib.utils import _RL_DIR
     if verbose is None: verbose=('-s' not in sys.argv)
+    cwd = os.getcwd()
+    docsDir=os.path.dirname(os.path.dirname(sys.argv[0]) or cwd)
+    topDir=os.path.dirname(docsDir)
+    sys.path.insert(0,topDir)
+    from tools.docco import yaml2pdf
     yaml2pdf.run('reference.yml','reference.pdf')
     if verbose: print 'Saved reference.pdf'
-    docdir = os.path.join(_RL_DIR,'docs')
-    if outDir: docDir = outDir
-    destfn = docdir + os.sep + 'reference.pdf'
+    if not outDir: outDir = os.path.join(topDir,'docs')
+    destfn = os.path.join(outDir,'reference.pdf')
     shutil.copyfile('reference.pdf', destfn)
     if verbose: print 'copied to %s' % destfn
 
--- a/docs/userguide/app_demos.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/app_demos.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/app_demos.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 
 Appendix1("ReportLab Demos")
 disc("""In the subdirectories of $reportlab/demos$ there are a number of working examples showing
@@ -110,4 +110,4 @@
 Exotic features of PDF such as fadeins and bookmarks are also shown to good effect. The use of
 an XML document can be contrasted with the <i>inline</i> style of the gadflypaper demo; the
 content is completely separate from the formatting
-""")
\ No newline at end of file
+""")
--- a/docs/userguide/ch1_intro.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch1_intro.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch1_intro.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 import reportlab
 
 title("ReportLab PDF Library")
@@ -478,7 +478,7 @@
 
 
 from reportlab.lib.codecharts import SingleByteEncodingChart
-from reportlab.tools.docco.stylesheet import getStyleSheet
+from tools.docco.stylesheet import getStyleSheet
 styles = getStyleSheet()
 indent0_style = styles['Indent0']
 indent1_style = styles['Indent1']
--- a/docs/userguide/ch2_graphics.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch2_graphics.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch2_graphics.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 from reportlab.lib.codecharts import SingleByteEncodingChart
 
 heading1("Graphics and Text with $pdfgen$")
--- a/docs/userguide/ch2a_fonts.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch2a_fonts.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch2a_fonts.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 from reportlab.lib.codecharts import SingleByteEncodingChart
 from reportlab.platypus import Image
 import reportlab
--- a/docs/userguide/ch3_pdffeatures.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch3_pdffeatures.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch3_pdffeatures.py
-from reportlab.tools.docco.rl_doc_utils import *
-
+from tools.docco.rl_doc_utils import *
 
 heading1("Exposing PDF Special Capabilities")
 disc("""PDF provides a number of features to make electronic
--- a/docs/userguide/ch4_platypus_concepts.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch4_platypus_concepts.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch4_platypus_concepts.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 
 #####################################################################################################3
 
--- a/docs/userguide/ch5_paragraphs.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch5_paragraphs.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch5_paragraphs.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 
 #begin chapter oon paragraphs
 heading1("Paragraphs")
--- a/docs/userguide/ch6_tables.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch6_tables.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch6_tables.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 from reportlab.platypus import Image
 import reportlab
 
--- a/docs/userguide/ch7_custom.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch7_custom.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch7_custom.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 
 heading1("Writing your own $Flowable$ Objects")
 disc("""
@@ -78,4 +78,4 @@
         Image.draw(self)
 I = RotatedImage('%s')
 I.hAlign = 'CENTER'
-""" % I,'I')
\ No newline at end of file
+""" % I,'I')
--- a/docs/userguide/ch9_future.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/ch9_future.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/ch9_future.py
-from reportlab.tools.docco.rl_doc_utils import *
+from tools.docco.rl_doc_utils import *
 
 heading1("Future Directions")
 
@@ -32,4 +32,4 @@
 look to $http://www.reportlab.com$ for the latest mailing list and
 contact information.""")
 
-# this comment is a trivial test of SF checkin rights - delete it some time!  AR 2001-04-17
\ No newline at end of file
+# this comment is a trivial test of SF checkin rights - delete it some time!  AR 2001-04-17
--- a/docs/userguide/genuserguide.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/docs/userguide/genuserguide.py	Wed Sep 03 16:18:43 2008 +0000
@@ -7,18 +7,22 @@
 This module contains the script for building the user guide.
 """
 def run(pagesize=None, verbose=0, outDir=None):
-    import os
-    from reportlab.tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
-    from reportlab.tools.docco import rl_doc_utils
-    from reportlab.lib.utils import open_and_read, _RL_DIR
-    if not outDir: outDir = os.path.join(_RL_DIR,'docs')
+    import sys,os
+    from reportlab.lib.utils import open_and_read
+    cwd = os.getcwd()
+    docsDir=os.path.dirname(os.path.dirname(sys.argv[0]) or cwd)
+    topDir=os.path.dirname(docsDir)
+    if not outDir: outDir=docsDir
+    G = {}
+    sys.path.insert(0,topDir)
+    from tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
+    from tools.docco import rl_doc_utils
+    exec 'from tools.docco.rl_doc_utils import *' in G, G
     destfn = os.path.join(outDir,'userguide.pdf')
     doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)
 
     #this builds the story
     setStory()
-    G = {}
-    exec 'from reportlab.tools.docco.rl_doc_utils import *' in G, G
     for f in (
         'ch1_intro',
         'ch2_graphics',
--- a/src/reportlab/pdfgen/pycanvas.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/src/reportlab/pdfgen/pycanvas.py	Wed Sep 03 16:18:43 2008 +0000
@@ -2,7 +2,7 @@
 # Author : Jerome Alet - <alet@librelogiciel.com>
 # License : ReportLab's license
 #
-# $Id: pycanvas.py,v 1.8 2002/11/06 17:11:15 rgbecker Exp $
+# $Id$
 #
 __doc__ = """pycanvas.Canvas : a Canvas class which can also output Python source code.
 
--- a/tests/runAll.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/runAll.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,16 +1,14 @@
 #!/usr/bin/env python
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/runAll.py
 """Runs all test files in all subfolders.
 """
-import os, glob, sys, string, traceback
-from reportlab.test import unittest
-from reportlab.test.utils import GlobDirectoryWalker, outputfile, printLocation
+__version__=''' $Id$ '''
+import os, glob, sys, string, traceback, unittest
+from tests.utils import GlobDirectoryWalker, outputfile, printLocation
 
 def makeSuite(folder, exclude=[],nonImportable=[],pattern='test_*.py'):
     "Build a test suite of all available test files."
-
     allTests = unittest.TestSuite()
 
     if os.path.isdir(folder): sys.path.insert(0, folder)
@@ -36,7 +34,7 @@
     except:
         folder = os.path.dirname(sys.argv[0]) or os.getcwd()
     #allow for Benn's "screwball cygwin distro":
-    if folder == '':
+    if not folder:
         folder = '.'
     from reportlab.lib.utils import isSourceDistro
     haveSRC = isSourceDistro()
@@ -79,7 +77,7 @@
         os.close(sys.stderr.fileno())
 
 def runExternally():
-    cmd = sys.executable+' -c"from reportlab.test import runAll;runAll.mainEx()"'
+    cmd = sys.executable+' -c"from tests import runAll;runAll.mainEx()"'
     i,o,e=os.popen3(cmd)
     i.close()
     out = o.read()
--- a/tests/test_charts_textlabels.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_charts_textlabels.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 import os, sys, copy
 from os.path import join, basename, splitext
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.lib import colors
 from reportlab.lib.units import cm
 from reportlab.lib.pagesizes import A4
--- a/tests/test_docs_build.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_docs_build.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,50 +1,43 @@
+__version__=''' $Id$ '''
 """Tests that all manuals can be built.
 """
-
-
-import os, sys
-
-from reportlab.test import unittest
-from reportlab.test.utils import SecureTestCase, printLocation
-
+import os, sys, unittest
+from tests.utils import SecureTestCase, printLocation, testsFolder
 
 class ManualTestCase(SecureTestCase):
     "Runs all 3 manual-builders from the top."
 
     def test0(self):
         "Test if all manuals buildable from source."
-
-        import reportlab
-        rlFolder = os.path.dirname(reportlab.__file__)
-        docsFolder = os.path.join(rlFolder, 'docs')
+        docsFolder = os.path.join(testsFolder,'..','docs')
+        cwd = os.getcwd()
         os.chdir(docsFolder)
+        try:
+            if os.path.isfile('userguide.pdf'):
+                os.remove('userguide.pdf')
+            if os.path.isfile('graphguide.pdf'):
+                os.remove('graphguide.pdf')
+            if os.path.isfile('reference.pdf'):
+                os.remove('reference.pdf')
+            if os.path.isfile('graphics_reference.pdf'):
+                os.remove('graphics_reference.pdf')
 
-        if os.path.isfile('userguide.pdf'):
-            os.remove('userguide.pdf')
-        if os.path.isfile('graphguide.pdf'):
-            os.remove('graphguide.pdf')
-        if os.path.isfile('reference.pdf'):
-            os.remove('reference.pdf')
-        if os.path.isfile('graphics_reference.pdf'):
-            os.remove('graphics_reference.pdf')
+            os.system("%s genAll.py -s" % sys.executable)
 
-        os.system("%s genAll.py -s" % sys.executable)
-
-        assert os.path.isfile('userguide.pdf'), 'genAll.py failed to generate userguide.pdf!'
-        assert os.path.isfile('graphguide.pdf'), 'genAll.py failed to generate graphguide.pdf!'
-        assert os.path.isfile('reference.pdf'), 'genAll.py failed to generate reference.pdf!'
-        assert os.path.isfile('graphics_reference.pdf'), 'genAll.py failed to generate graphics_reference.pdf!'
-
+            assert os.path.isfile('userguide.pdf'), 'genAll.py failed to generate userguide.pdf!'
+            assert os.path.isfile('graphguide.pdf'), 'genAll.py failed to generate graphguide.pdf!'
+            assert os.path.isfile('reference.pdf'), 'genAll.py failed to generate reference.pdf!'
+            assert os.path.isfile('graphics_reference.pdf'), 'genAll.py failed to generate graphics_reference.pdf!'
+        finally:
+            os.chdir(cwd)
 
 def makeSuite():
     suite = unittest.TestSuite()
     loader = unittest.TestLoader()
     if sys.platform[:4] != 'java':
         suite.addTest(loader.loadTestsFromTestCase(ManualTestCase))
-
     return suite
 
-
 #noruntests
 if __name__ == "__main__":
     unittest.TextTestRunner().run(makeSuite())
--- a/tests/test_docstrings.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_docstrings.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,7 +1,6 @@
 #!/usr/bin/env python
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_docstrings.py
 
 """This is a test on a package level that find all modules,
 classes, methods and functions that do not have a doc string
@@ -10,16 +9,10 @@
 Currently, methods with leading and trailing double underscores
 are skipped.
 """
-
-import os, sys, glob, string, re
+import os, sys, glob, string, re, unittest
 from types import ModuleType, ClassType, MethodType, FunctionType
-
+from tests.utils import SecureTestCase, GlobDirectoryWalker, outputfile, printLocation, RL_HOME
 import reportlab
-from reportlab.test import unittest
-from reportlab.test.utils import SecureTestCase, GlobDirectoryWalker, outputfile, printLocation
-
-
-RL_HOME = os.path.dirname(reportlab.__file__)
 
 def getModuleObjects(folder, rootName, typ, pattern='*.py'):
     "Get a list of all objects defined *somewhere* in a package."
--- a/tests/test_extra.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_extra.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,20 +1,10 @@
 """This executes tests defined outside the normal test suite.
-
 See docstring for class ExternalTestCase for more information.
 """
-
-
-import os, string, fnmatch, re, sys
-
-import reportlab
-from reportlab.test import unittest
-from reportlab.test.utils import SecureTestCase, printLocation
-
-
-RL_HOME = os.path.dirname(reportlab.__file__)
+import os, string, fnmatch, re, sys, unittest
+from tests.utils import SecureTestCase, printLocation, RL_HOME
 EXTRA_FILE = 'extra.txt'
 
-
 class ExternalTestCase(SecureTestCase):
     """Test case starting cases external to the normal RL suite.
 
--- a/tests/test_graphics_charts.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_graphics_charts.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 import os, sys, copy
 from os.path import join, basename, splitext
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.lib import colors
 from reportlab.lib.units import cm
 from reportlab.lib.pagesizes import A4
--- a/tests/test_graphics_images.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_graphics_images.py	Wed Sep 03 16:18:43 2008 +0000
@@ -6,8 +6,8 @@
 
 import os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.graphics.shapes import Image, Drawing
 from reportlab.graphics import renderPDF
--- a/tests/test_graphics_layout.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_graphics_layout.py	Wed Sep 03 16:18:43 2008 +0000
@@ -5,8 +5,8 @@
 Tests for getBounds methods of various graphical widgets
 """
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation
 
 from reportlab.graphics import shapes
 ##from reportlab.graphics.charts.barcharts import VerticalBarChart
--- a/tests/test_graphics_speed.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_graphics_speed.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 __version__ = ''' $Id $ '''
 import os, sys, time
 import reportlab.rl_config
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.lib import colors
 from reportlab.lib.units import cm
 from reportlab.pdfgen.canvas import Canvas
--- a/tests/test_hello.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_hello.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 Useful if you want to test that a really minimal PDF is healthy,
 since the output is about the smallest thing we can make."""
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.pdfgen.canvas import Canvas
 
 
--- a/tests/test_images.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_images.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,15 +1,14 @@
 #!/bin/env python
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_images.py
-__version__=''' $Id'''
+__version__='''$Id$'''
 __doc__="""Tests to do with image handling.
 
 Most of them make use of test\pythonpowereed.gif."""
 import os,md5
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation, testsFolder
 from reportlab.lib.utils import ImageReader
 
 
@@ -17,38 +16,30 @@
 attach its 'file contents' here in several formats.
 
 The image looks like this, with K=black, R=red, G=green, B=blue, W=white.
-
     K R G B W
     K R G B W
     K R G B W
     K R G B W
     K R G B W
-
 """
-
 sampleRAW = '\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\xff\xff\xff'
 samplePNG = '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x05\x00\x00\x00\x05\x08\x02\x00\x00\x00\x02\r\xb1\xb2\x00\x00\x00:IDATx\x9cb```\xf8\x0f\xc3\xff\xff\xff\x07\x00\x00\x00\xff\xffbb@\x05\x00\x00\x00\x00\xff\xffB\xe7\x03\x00\x00\x00\xff\xffB\xe7\x03\x00\x00\x00\xff\xffB\xe7\x03\x00\x00\x00\xff\xff\x03\x00\x9e\x01\x06\x03\x03\xc4A\xb4\x00\x00\x00\x00IEND\xaeB`\x82'
 
-
 class ReaderTestCase(unittest.TestCase):
     "Simplest tests to import images, work under Jython or PIL"
 
     def test(self):
-        import reportlab.test
         from reportlab.lib.utils import rl_isfile
-        imageFileName = os.path.dirname(reportlab.test.__file__) + os.sep + 'pythonpowered.gif'
+        imageFileName = os.path.join(testsFolder,'pythonpowered.gif')
         assert rl_isfile(imageFileName), "%s not found!" % imageFileName
-
         ir = ImageReader(imageFileName)
         assert ir.getSize() == (110,44)
         pixels = ir.getRGBData()
         assert md5.md5(pixels).hexdigest() == '02e000bf3ffcefe9fc9660c95d7e27cf'
 
-
 def makeSuite():
     return makeSuiteForClasses(ReaderTestCase)
 
-
 #noruntests
 if __name__ == "__main__":
     unittest.TextTestRunner().run(makeSuite())
--- a/tests/test_invariant.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_invariant.py	Wed Sep 03 16:18:43 2008 +0000
@@ -7,8 +7,8 @@
 make identical file.  This does NOT test across platforms
 or python versions, only a user can do that :-)"""
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 from reportlab.pdfgen.canvas import Canvas
 filename = outputfile('test_invariant.pdf')
 
@@ -20,7 +20,7 @@
         c = Canvas(filename, invariant=1, pageCompression=0)
         c.setFont('Helvetica-Bold', 36)
         c.drawString(100,700, 'Hello World')
-        gif = os.path.join(os.path.dirname(unittest.__file__),'pythonpowered.gif')
+        gif = os.path.join(testsFolder,'pythonpowered.gif')
         c.drawImage(gif,100,600)
         c.save()
 
--- a/tests/test_lib_colors.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_lib_colors.py	Wed Sep 03 16:18:43 2008 +0000
@@ -7,8 +7,8 @@
 
 import os, math
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfgen.canvas import Canvas
 import reportlab.pdfgen.canvas
--- a/tests/test_lib_sequencer.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_lib_sequencer.py	Wed Sep 03 16:18:43 2008 +0000
@@ -7,8 +7,8 @@
 
 import sys, random
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation
 from reportlab.lib.sequencer import Sequencer
 
 
--- a/tests/test_lib_utils.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_lib_utils.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,13 +1,25 @@
+#Copyright ReportLab Europe Ltd. 2000-2008
+#see license.txt for license details
 """Tests for reportlab.lib.utils
 """
+__version__=''' $Id$ '''
 import os
 import reportlab
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation, testsFolder
 from reportlab.lib import colors
 from reportlab.lib.utils import recursiveImport, recursiveGetAttr, recursiveSetAttr, rl_isfile, \
                                 isCompactDistro
 
+def _rel_open_and_read(fn):
+    from reportlab.lib.utils import open_and_read
+    cwd = os.getcwd()
+    os.chdir(testsFolder)
+    try:
+        return open_and_read(fn)
+    finally:
+        os.chdir(cwd)
+
 class ImporterTestCase(unittest.TestCase):
     "Test import utilities"
     count = 0
@@ -36,7 +48,7 @@
 
     def test2(self):
         "try under a well known directory NOT on the path"
-        D = os.path.join(os.path.dirname(reportlab.__file__), 'tools','pythonpoint')
+        D = os.path.join(testsFolder,'..','tools','pythonpoint')
         fn = os.path.join(D,'stdparser.py')
         if rl_isfile(fn) or rl_isfile(fn+'c') or rl_isfile(fn+'o'):
             m1 = recursiveImport('stdparser', baseDir=D)
@@ -87,13 +99,11 @@
 
     def test7(self):
         "test open and read of a simple relative file"
-        from reportlab.lib.utils import open_and_read
-        b = open_and_read('../docs/images/Edit_Prefs.gif')
+        b = _rel_open_and_read('../docs/images/Edit_Prefs.gif')
 
     def test8(self):
         "test open and read of a relative file: URL"
-        from reportlab.lib.utils import open_and_read
-        b = open_and_read('file:../docs/images/Edit_Prefs.gif')
+        b = _rel_open_and_read('file:../docs/images/Edit_Prefs.gif')
 
     def test9(self):
         "test open and read of an http: URL"
@@ -103,13 +113,12 @@
     def test10(self):
         "test open and read of a simple relative file"
         from reportlab.lib.utils import open_and_read, getStringIO
-        b = getStringIO(open_and_read('../docs/images/Edit_Prefs.gif'))
+        b = getStringIO(_rel_open_and_read('../docs/images/Edit_Prefs.gif'))
         b = open_and_read(b)
 
 def makeSuite():
     return makeSuiteForClasses(ImporterTestCase)
 
-
 if __name__ == "__main__": #noruntests
     unittest.TextTestRunner().run(makeSuite())
     printLocation()
--- a/tests/test_lib_validators.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_lib_validators.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,8 @@
 """Tests (incomplete) for the reportlab.lib.validators module.
 """
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation
 from reportlab.lib import colors
 from reportlab.lib import validators
 
--- a/tests/test_multibyte_chs.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_multibyte_chs.py	Wed Sep 03 16:18:43 2008 +0000
@@ -10,8 +10,8 @@
 
 import string, os
 import codecs
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfbase import pdfmetrics
 from reportlab.pdfgen.canvas import Canvas
--- a/tests/test_multibyte_cht.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_multibyte_cht.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 
 import string, os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfbase import pdfmetrics
 from reportlab.pdfgen.canvas import Canvas
--- a/tests/test_multibyte_jpn.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_multibyte_jpn.py	Wed Sep 03 16:18:43 2008 +0000
@@ -10,8 +10,8 @@
 
 import string, os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfbase import pdfmetrics
 from reportlab.pdfgen.canvas import Canvas
--- a/tests/test_multibyte_kor.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_multibyte_kor.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,8 @@
 
 import string, os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfbase import pdfmetrics
 from reportlab.pdfgen.canvas import Canvas
--- a/tests/test_paragraphs.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_paragraphs.py	Wed Sep 03 16:18:43 2008 +0000
@@ -3,8 +3,8 @@
 #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_paragraphs.py
 # tests some paragraph styles
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.platypus import Paragraph, SimpleDocTemplate, XBox, Indenter, XPreformatted
 from reportlab.lib.styles import ParagraphStyle
--- a/tests/test_pdfbase_encodings.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfbase_encodings.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,5 +1,5 @@
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation, NearTestCase
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, NearTestCase
 
 from reportlab.pdfgen.canvas import Canvas
 from reportlab.pdfbase import pdfmetrics
--- a/tests/test_pdfbase_fontembed.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfbase_fontembed.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,11 +1,11 @@
 import os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfgen.canvas import Canvas
 from reportlab.pdfbase import pdfmetrics
-from reportlab.test.test_pdfbase_pdfmetrics import makeWidthTestForAllGlyphs
+from tests.test_pdfbase_pdfmetrics import makeWidthTestForAllGlyphs
 
 
 class EmbeddingTestCase(unittest.TestCase):
--- a/tests/test_pdfbase_pdfmetrics.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfbase_pdfmetrics.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 The main test prints out a PDF documents enabling checking of widths of every
 glyph in every standard font.  Long!
 """
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.pdfbase import pdfmetrics
 from reportlab.pdfbase import _fontdata
 from reportlab.pdfgen.canvas import Canvas
--- a/tests/test_pdfbase_pdfutils.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfbase_pdfutils.py	Wed Sep 03 16:18:43 2008 +0000
@@ -7,8 +7,8 @@
 
 import os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation
 
 from reportlab.pdfbase.pdfutils import _AsciiHexEncode, _AsciiHexDecode
 from reportlab.pdfbase.pdfutils import _AsciiBase85Encode, _AsciiBase85Decode
--- a/tests/test_pdfbase_postscript.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfbase_postscript.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 contain graphics and tray commands if exported to
 a Postscript device in Acrobat 4.0"""
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.pdfgen.canvas import Canvas
 
 
--- a/tests/test_pdfbase_ttfonts.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfbase_ttfonts.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 import string
 from cStringIO import StringIO
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation, NearTestCase
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, NearTestCase
 
 from reportlab.pdfgen.canvas import Canvas
 from reportlab.pdfbase import pdfmetrics
--- a/tests/test_pdfgen_callback.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfgen_callback.py	Wed Sep 03 16:18:43 2008 +0000
@@ -5,11 +5,11 @@
 __version__=''' $Id$ '''
 __doc__='checks callbacks work'
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfgen.canvas import Canvas
-from reportlab.test.test_pdfgen_general import makeDocument
+from tests.test_pdfgen_general import makeDocument
 
 _PAGE_COUNT = 0
 
--- a/tests/test_pdfgen_general.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfgen_general.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 
 import os, string
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 
 from reportlab.pdfgen import canvas   # gmcm 2000/10/13, pdfgen now a package
 from reportlab.lib.units import inch, cm
@@ -669,7 +669,7 @@
     c.drawText(t)
 
     if haveImages:
-        gif = os.path.join(os.path.dirname(unittest.__file__),'pythonpowered.gif')
+        gif = os.path.join(testsFolder,'pythonpowered.gif')
         c.drawInlineImage(gif,2*inch, 7*inch)
     else:
         c.rect(2*inch, 7*inch, 110, 44)
@@ -727,10 +727,10 @@
     c.rect(1*inch, 6+14.4*inch, w, h)
     c.rect(3*inch, 6+14.4*inch, w, h)
     if haveImages:
-        png = os.path.join(os.path.dirname(unittest.__file__),'solid_red_alpha.png')
+        png = os.path.join(testsFolder,'solid_red_alpha.png')
         c.drawImage(png, 1*inch, 8*inch+14.4, w, h, mask=None)
         c.drawImage(png, 3*inch, 8*inch+14.4, w, h, mask='auto')
-        png = os.path.join(os.path.dirname(unittest.__file__),'alpha_test.png')
+        png = os.path.join(testsFolder,'alpha_test.png')
         c.drawImage(png, 1*inch, 6*inch+14.4, w, h, mask=None)
         c.drawImage(png, 3*inch, 6*inch+14.4, w, h, mask='auto')
     c.showPage()
--- a/tests/test_pdfgen_links.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfgen_links.py	Wed Sep 03 16:18:43 2008 +0000
@@ -21,8 +21,8 @@
 from reportlab.lib.pagesizes import letter
 from reportlab.lib import colors
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 def markPage(c,height=letter[1],width=letter[0]):
     height = height / inch
--- a/tests/test_pdfgen_pagemodes.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfgen_pagemodes.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 
 import os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfgen.canvas import Canvas
 
--- a/tests/test_pdfgen_pycanvas.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pdfgen_pycanvas.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,19 +1,17 @@
 #!/bin/env python
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
 __version__=''' $Id$ '''
 __doc__='testscript for reportlab.pdfgen'
 #tests and documents new low-level canvas and the pycanvas module to output Python source code.
 
-import string, os
-
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import string, os, unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 
 from reportlab.pdfgen import pycanvas   # gmcm 2000/10/13, pdfgen now a package
 from reportlab.lib.units import inch, cm
 from reportlab.lib import colors
-from reportlab.lib.utils import haveImages, _RL_DIR, rl_isfile
+from reportlab.lib.utils import haveImages, rl_isfile
 
 #################################################################
 #
@@ -639,8 +637,8 @@
         space if you use images more than once.""")
 
     c.drawText(t)
-
-    gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
+    import tests
+    gif = os.path.join(testsFolder,'pythonpowered.gif')
     if haveImages and rl_isfile(gif):
         c.drawInlineImage(gif,2*inch, 7*inch)
     else:
--- a/tests/test_platypus_breaking.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_breaking.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 from operator import truth
 from types import StringType, ListType
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.platypus.flowables import Flowable
 from reportlab.lib import colors
--- a/tests/test_platypus_general.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_general.py	Wed Sep 03 16:18:43 2008 +0000
@@ -12,12 +12,8 @@
 builds a special "document model" in which the frames are added to each page
 and drawn into.
 """
-
 import string, copy, sys, os
-
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
-
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 from reportlab.pdfgen import canvas
 from reportlab import platypus
 from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
@@ -27,14 +23,16 @@
 from reportlab.lib import colors
 from reportlab.rl_config import defaultPageSize
 from reportlab.lib.utils import haveImages, _RL_DIR, rl_isfile, open_for_read, fileName2Utf8
+import unittest
+import tests
 if haveImages:
-    _GIF = os.path.join(_RL_DIR,'test','pythonpowered.gif')
+    _GIF = os.path.join(testsFolder,'pythonpowered.gif')
     if not rl_isfile(_GIF): _GIF = None
 else:
     _GIF = None
 if _GIF: _GIFUTF8=fileName2Utf8(_GIF)
 
-_JPG = os.path.join(_RL_DIR,'docs','images','lj8100.jpg')
+_JPG = os.path.join(testsFolder,'..','docs','images','lj8100.jpg')
 if not rl_isfile(_JPG): _JPG = None
 
 def getFurl(fn):
@@ -285,7 +283,7 @@
     reportlab.rl_config.warnOnMissingFontGlyphs = 0
 
     from reportlab.pdfbase import pdfmetrics
-    fontDir = os.path.join(os.path.dirname(reportlab.__file__),'fonts')
+    fontDir = os.path.join(_RL_DIR,'fonts')
     face = pdfmetrics.EmbeddedType1Face(os.path.join(fontDir,'LeERC___.AFM'),
             os.path.join(fontDir,'LeERC___.PFB'))
     faceName = face.name  # should be 'LettErrorRobot-Chrome'
@@ -468,7 +466,7 @@
     reportlab.rl_config.warnOnMissingFontGlyphs = 0
 
     from reportlab.pdfbase import pdfmetrics
-    fontDir = os.path.join(os.path.dirname(reportlab.__file__),'fonts')
+    fontDir = os.path.join(_RL_DIR,'fonts')
     face = pdfmetrics.EmbeddedType1Face(os.path.join(fontDir,'LeERC___.AFM'),os.path.join(fontDir,'LeERC___.PFB'))
     faceName = face.name  # should be 'LettErrorRobot-Chrome'
     pdfmetrics.registerTypeFace(face)
@@ -582,7 +580,7 @@
 
         story = [Paragraph("The section header", header), d,
                 ]
-        doc = SimpleDocTemplate('test_drawing_keepwithnext.pdf')
+        doc = SimpleDocTemplate(outputfile('test_drawing_keepwithnext.pdf'))
         doc.build(story)
 
     def test2(self):
@@ -610,7 +608,7 @@
                 DocWhile('i',[DocPara('i',format='The value of i is %(__expr__)d',style=normal),DocExec('i-=1')]),
                 DocPara('repr(doc._nameSpace)',escape=True),
                 ]
-        doc = SimpleDocTemplate('test_doc_programming.pdf')
+        doc = SimpleDocTemplate(outputfile('test_doc_programming.pdf'))
         doc.build(story)
 
 def makeSuite():
--- a/tests/test_platypus_indents.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_indents.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 from operator import truth
 from types import StringType, ListType
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.pdfbase.pdfmetrics import stringWidth
 from reportlab.platypus.paraparser import ParaParser
--- a/tests/test_platypus_leftright.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_leftright.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 from operator import truth
 from types import StringType, ListType
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.platypus.flowables import Flowable
 from reportlab.lib import colors
--- a/tests/test_platypus_paragraphs.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_paragraphs.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,16 +1,14 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_platypus_paragraphs.py
 """Tests for the reportlab.platypus.paragraphs module.
 """
+__version__=''' $Id$ '''
 
-import sys, os
+import sys, os, unittest
 from string import split, strip, join, whitespace
 from operator import truth
 from types import StringType, ListType
-
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 
 from reportlab.pdfbase.pdfmetrics import stringWidth, registerFont, registerFontFamily
 from reportlab.pdfbase.ttfonts import TTFont
@@ -123,8 +121,8 @@
 it's actually easy to do using platypus.
 '''
         from reportlab.platypus.flowables import ParagraphAndImage, Image
-        from reportlab.lib.utils import _RL_DIR
-        gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
+        import tests
+        gif = os.path.join(testsFolder,'pythonpowered.gif')
         story.append(ParagraphAndImage(Paragraph(text,bt),Image(gif)))
         phrase = 'This should be a paragraph spanning at least three pages. '
         description = ''.join([('%d: '%i)+phrase for i in xrange(250)])
@@ -160,8 +158,8 @@
 your browser. If an internal link begins with something that looks like a scheme, precede with "document:". <strike>This text should have a strike through it.</strike>
 '''
         from reportlab.platypus.flowables import ImageAndFlowables, Image
-        from reportlab.lib.utils import _RL_DIR
-        gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
+        import tests
+        gif = os.path.join(testsFolder,'pythonpowered.gif')
         heading = Paragraph('This is a heading',h3)
         story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text,bt)]))
         phrase = 'This should be a paragraph spanning at least three pages. '
@@ -391,11 +389,11 @@
         normal_sp = ParagraphStyle(name='normal_sp',parent=normal,alignment=TA_JUSTIFY,spaceBefore=12)
         texts = ['''Furthermore, a subset of <font size="14">English sentences</font> interesting on quite
 independent grounds is not quite equivalent to a stipulation to place
-<font color="blue">the constructions <img src="../docs/images/testimg.gif"/> into these various categories.</font>''',
+<font color="blue">the constructions <img src="%(testsFolder)s/../docs/images/testimg.gif"/> into these various categories.</font>'''%dict(testsFolder=testsFolder),
         '''We will bring <font size="18">Ugly Things</font> in favor of
 The following thesis:  most of the methodological work in Modern
-Linguistics can be <img src="../docs/images/testimg.gif" valign="baseline" /> defined in such <img src="../docs/images/testimg.gif" valign="10" /> a way as to impose problems of
-phonemic and <u>morphological <img src="../docs/images/testimg.gif" valign="top"/> </u> analysis.''']
+Linguistics can be <img src="%(testsFolder)s/../docs/images/testimg.gif" valign="baseline" /> defined in such <img src="%(testsFolder)s/../docs/images/testimg.gif" valign="10" /> a way as to impose problems of
+phonemic and <u>morphological <img src="%(testsFolder)s/../docs/images/testimg.gif" valign="top"/> </u> analysis.'''%dict(testsFolder=testsFolder)]
         story =[]
         a = story.append
         t = 'u'
@@ -407,16 +405,16 @@
                             autoLeading,
                             t,' '.join((n+1)*['A']),t,texts[0],t,' '.join((n+1)*['A']),t,texts[1]),
                             style=s))
-        a(Paragraph('''<img src="../docs/images/testimg.gif" valign="top"/> image is very first thing in the line.''', style=normal))
+        a(Paragraph('''<img src="%(testsFolder)s/../docs/images/testimg.gif" valign="top"/> image is very first thing in the line.'''%dict(testsFolder=testsFolder), style=normal))
         a(Paragraph('some text.... some more.... some text.... some more....', normal))
-        a(Paragraph('<img src="../docs/images/testimg.gif" width="0.57in" height="0.19in" /> some text <br /> ', normal))
+        a(Paragraph('<img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="0.19in" /> some text <br /> '%dict(testsFolder=testsFolder), normal))
         a(Paragraph('some text.... some more.... some text.... some more....', normal))
-        a(Paragraph('<img src="../docs/images/testimg.gif" width="0.57in" height="0.19in" /> <br /> ', normal))
+        a(Paragraph('<img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="0.19in" /> <br /> '%dict(testsFolder=testsFolder), normal))
         a(Paragraph('some text.... some more.... some text.... some more....', normal))
 
         #Volker Haas' valign tests
         fmt = '''<font color="red">%(valign)s</font>: Furthermore, a <u>subset</u> <strike>of</strike> <font size="14">English sentences</font> interesting on quite
-independent grounds is not quite equivalent to a stipulation to place <img src="../docs/images/redsquare.png" width="0.5in" height="0.5in" valign="%(valign)s"/>
+independent grounds is not quite equivalent to a stipulation to place <img src="%(testsFolder)s/../docs/images/redsquare.png" width="0.5in" height="0.5in" valign="%(valign)s"/>
 the constructions into these <u>various</u> categories. We will bring <font size="18">Ugly Things</font> in favor of
 The following thesis:  most of the methodological work in Modern
 Linguistics can be defined in such a way as to impose problems of
@@ -436,8 +434,8 @@
                 '0%',
                 '2in',
                 ):
-            a(Paragraph(fmt % {'valign':valign},p_style))
-            a(XPreformatted(fmt % {'valign':valign},p_style))
+            a(Paragraph(fmt % dict(valign=valign,testsFolder=testsFolder),p_style))
+            a(XPreformatted(fmt % dict(valign=valign,testsFolder=testsFolder),p_style))
         doc = MyDocTemplate(outputfile('test_platypus_paragraphs_autoleading.pdf'))
         doc.build(story)
 
--- a/tests/test_platypus_paraparser.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_paraparser.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 from types import TupleType, ListType, StringType, UnicodeType
 from pprint import pprint as pp
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile
 from reportlab.platypus import cleanBlockQuotedText
 from reportlab.platypus.paraparser import ParaParser, ParaFrag
 from reportlab.lib.colors import black
--- a/tests/test_platypus_pleaseturnover.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_pleaseturnover.py	Wed Sep 03 16:18:43 2008 +0000
@@ -6,8 +6,8 @@
 
 import sys
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 from reportlab.platypus.flowables import Flowable, PTOContainer, KeepInFrame
 from reportlab.lib.units import cm
 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
--- a/tests/test_platypus_tables.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_tables.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,12 +1,11 @@
 #!/bin/env python
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_platypus_tables.py
 __version__=''' $Id$ '''
 __doc__='Test script for reportlab.tables'
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import os,unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle
 from reportlab.lib.units import inch, cm
 from reportlab.lib import colors
@@ -509,8 +508,7 @@
         lst.append(Spacer(0,6))
 
     lst.append(PageBreak())
-    import os, reportlab.platypus
-    I = Image(os.path.join(os.path.dirname(reportlab.platypus.__file__),'..','tools','pythonpoint','demos','leftlogo.gif'))
+    I = Image(os.path.join(os.path.dirname(testsFolder),'tools','pythonpoint','demos','leftlogo.gif'))
     I.drawHeight = 1.25*inch*I.drawHeight / I.drawWidth
     I.drawWidth = 1.25*inch
     #I.drawWidth = 9.25*inch #uncomment to see better messaging
--- a/tests/test_platypus_toc.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_toc.py	Wed Sep 03 16:18:43 2008 +0000
@@ -13,8 +13,8 @@
 from os.path import join, basename, splitext
 from math import sqrt
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.lib.units import inch, cm
 from reportlab.lib.pagesizes import A4
--- a/tests/test_platypus_xref.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_platypus_xref.py	Wed Sep 03 16:18:43 2008 +0000
@@ -9,8 +9,8 @@
 from operator import truth
 from types import StringType, ListType
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.lib import colors
 from reportlab.lib.units import cm
--- a/tests/test_pyfiles.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_pyfiles.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,22 +1,14 @@
 #Copyright ReportLab Europe Ltd. 2000-2004
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_pyfiles.py
+__version__=''' $Id$ '''
 """Tests performed on all Python source files of the ReportLab distribution.
 """
-
-
 import os, sys, string, fnmatch, re
-
-import reportlab
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, SecureTestCase, GlobDirectoryWalker, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, SecureTestCase, GlobDirectoryWalker, outputfile, printLocation, RL_HOME
 from reportlab.lib.utils import open_and_read, open_and_readlines
 
-RL_HOME = os.path.dirname(reportlab.__file__)
-
-
 # Helper function and class.
-
 def unique(seq):
     "Remove elements from a list that occur more than once."
 
@@ -73,8 +65,6 @@
 
     def testAscii(self):
         "Test if Python files are pure ASCII ones."
-
-        RL_HOME = os.path.dirname(reportlab.__file__)
         allPyFiles = GlobDirectoryWalker(RL_HOME, '*.py')
 
         for path in allPyFiles:
--- a/tests/test_renderSVG.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_renderSVG.py	Wed Sep 03 16:18:43 2008 +0000
@@ -4,8 +4,8 @@
 from xml.dom import minidom
 from xml.sax._exceptions import SAXReaderNotAvailable
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.graphics.shapes import *
 from reportlab.graphics import renderSVG
--- a/tests/test_rl_accel.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_rl_accel.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,8 @@
 __version__=''' $Id'''
 __doc__='''basic tests.'''
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation
 
 def getrc(defns,depth=1):
     from sys import getrefcount, _getframe
--- a/tests/test_source_chars.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_source_chars.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,17 +1,14 @@
 #!/usr/bin/env python
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_source_chars.py
-
 """This tests for things in source files.  Initially, absence of tabs :-)
 """
-
+__version__=''' $Id$ '''
 import os, sys, glob, string, re
 from types import ModuleType, ClassType, MethodType, FunctionType
-
 import reportlab
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, SecureTestCase, GlobDirectoryWalker, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, SecureTestCase, GlobDirectoryWalker, printLocation, testsFolder, RL_HOME
 from reportlab.lib.utils import open_and_read
 
 
@@ -49,8 +46,7 @@
             self.output.write("file %s contains %d trailing spaces, or %0.2f%% wastage\n" % (filename, badChars, 100.0*badChars/initSize))
 
     def testFiles(self):
-        topDir = os.path.dirname(reportlab.__file__)
-        w = GlobDirectoryWalker(topDir, '*.py')
+        w = GlobDirectoryWalker(RL_HOME, '*.py')
         for filename in w:
             self.checkFileForTabs(filename)
             self.checkFileForTrailingSpaces(filename)
--- a/tests/test_table_layout.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_table_layout.py	Wed Sep 03 16:18:43 2008 +0000
@@ -12,8 +12,8 @@
 
 import os
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 
 from types import TupleType, ListType, StringType
--- a/tests/test_tools_pythonpoint.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_tools_pythonpoint.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,8 +1,8 @@
 """Tests for the PythonPoint tool.
 """
 import os, sys, string
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation, testsFolder
 import reportlab
 
 class PythonPointTestCase(unittest.TestCase):
@@ -11,8 +11,7 @@
         "Test if pythonpoint.pdf can be created from pythonpoint.xml."
 
         join, dirname, isfile, abspath = os.path.join, os.path.dirname, os.path.isfile, os.path.abspath
-        rlDir = abspath(dirname(reportlab.__file__))
-        from reportlab.tools.pythonpoint import pythonpoint
+        from tools.pythonpoint import pythonpoint
         from reportlab.lib.utils import isCompactDistro, open_for_read
         ppDir = dirname(pythonpoint.__file__)
         xml = join(ppDir, 'demos', 'pythonpoint.xml')
--- a/tests/test_utils.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_utils.py	Wed Sep 03 16:18:43 2008 +0000
@@ -4,8 +4,8 @@
 __version__='''$Id$'''
 __doc__="""Test reportlab.lib.util module"""
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 
 class FmtTestCase(unittest.TestCase):
--- a/tests/test_widgetbase_tpc.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_widgetbase_tpc.py	Wed Sep 03 16:18:43 2008 +0000
@@ -8,8 +8,8 @@
 import os, sys, copy
 from os.path import join, basename, splitext
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, printLocation
 
 from reportlab.graphics.widgetbase import PropHolder, TypedPropertyCollection
 from reportlab.lib.attrmap import AttrMap, AttrMapValue
--- a/tests/test_widgets_grids.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/test_widgets_grids.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,6 +1,6 @@
 
-from reportlab.test import unittest
-from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+import unittest
+from tests.utils import makeSuiteForClasses, outputfile, printLocation
 
 from reportlab.lib import colors
 from reportlab.graphics.shapes import Drawing, Group, Line, Rect
--- a/tests/unittest.py	Wed Sep 03 16:11:36 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,723 +0,0 @@
-#!/usr/bin/env python
-'''
-Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
-Smalltalk testing framework.
-
-This module contains the core framework classes that form the basis of
-specific test cases and suites (TestCase, TestSuite etc.), and also a
-text-based utility class for running the tests and reporting the results
- (TextTestRunner).
-
-Simple usage:
-
-    import unittest
-
-    class IntegerArithmenticTestCase(unittest.TestCase):
-        def testAdd(self):  ## test method names begin 'test*'
-            self.assertEquals((1 + 2), 3)
-            self.assertEquals(0 + 1, 1)
-        def testMultiply(self):
-            self.assertEquals((0 * 10), 0)
-            self.assertEquals((5 * 8), 40)
-
-    if __name__ == '__main__':
-        unittest.main()
-
-Further information is available in the bundled documentation, and from
-
-  http://pyunit.sourceforge.net/
-
-Copyright (c) 1999, 2000, 2001 Steve Purcell
-This module is free software, and you may redistribute it and/or modify
-it under the same terms as Python itself, so long as this copyright message
-and disclaimer are retained in their original form.
-
-IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
-THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
-AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
-SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-'''
-
-__author__ = "Steve Purcell"
-__email__ = "stephen_purcell at yahoo dot com"
-__version__ = "#Revision: 1.43 $"[11:-2]
-
-import time
-import sys
-import traceback
-import string
-import os
-import types
-
-##############################################################################
-# Test framework core
-##############################################################################
-
-class TestResult:
-    """Holder for test result information.
-
-    Test results are automatically managed by the TestCase and TestSuite
-    classes, and do not need to be explicitly manipulated by writers of tests.
-
-    Each instance holds the total number of tests run, and collections of
-    failures and errors that occurred among those test runs. The collections
-    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
-    formatted traceback of the error that occurred.
-    """
-    def __init__(self):
-        self.failures = []
-        self.errors = []
-        self.testsRun = 0
-        self.shouldStop = 0
-
-    def startTest(self, test):
-        "Called when the given test is about to be run"
-        self.testsRun = self.testsRun + 1
-
-    def stopTest(self, test):
-        "Called when the given test has been run"
-        pass
-
-    def addError(self, test, err):
-        """Called when an error has occurred. 'err' is a tuple of values as
-        returned by sys.exc_info().
-        """
-        self.errors.append((test, self._exc_info_to_string(err)))
-
-    def addFailure(self, test, err):
-        """Called when an error has occurred. 'err' is a tuple of values as
-        returned by sys.exc_info()."""
-        self.failures.append((test, self._exc_info_to_string(err)))
-
-    def addSuccess(self, test):
-        "Called when a test has completed successfully"
-        pass
-
-    def wasSuccessful(self):
-        "Tells whether or not this result was a success"
-        return len(self.failures) == len(self.errors) == 0
-
-    def stop(self):
-        "Indicates that the tests should be aborted"
-        self.shouldStop = 1
-
-    def _exc_info_to_string(self, err):
-        """Converts a sys.exc_info()-style tuple of values into a string."""
-        return string.join(apply(traceback.format_exception, err), '')
-
-    def __repr__(self):
-        return "<%s run=%i errors=%i failures=%i>" % \
-               (self.__class__, self.testsRun, len(self.errors),
-                len(self.failures))
-
-
-class TestCase:
-    """A class whose instances are single test cases.
-
-    By default, the test code itself should be placed in a method named
-    'runTest'.
-
-    If the fixture may be used for many test cases, create as
-    many test methods as are needed. When instantiating such a TestCase
-    subclass, specify in the constructor arguments the name of the test method
-    that the instance is to execute.
-
-    Test authors should subclass TestCase for their own tests. Construction
-    and deconstruction of the test's environment ('fixture') can be
-    implemented by overriding the 'setUp' and 'tearDown' methods respectively.
-
-    If it is necessary to override the __init__ method, the base class
-    __init__ method must always be called. It is important that subclasses
-    should not change the signature of their __init__ method, since instances
-    of the classes are instantiated automatically by parts of the framework
-    in order to be run.
-    """
-
-    # This attribute determines which exception will be raised when
-    # the instance's assertion methods fail; test methods raising this
-    # exception will be deemed to have 'failed' rather than 'errored'
-
-    failureException = AssertionError
-
-    def __init__(self, methodName='runTest'):
-        """Create an instance of the class that will use the named test
-           method when executed. Raises a ValueError if the instance does
-           not have a method with the specified name.
-        """
-        try:
-            self.__testMethodName = methodName
-            testMethod = getattr(self, methodName)
-            self.__testMethodDoc = testMethod.__doc__
-        except AttributeError:
-            raise ValueError, "no such test method in %s: %s" % \
-                  (self.__class__, methodName)
-
-    def setUp(self):
-        "Hook method for setting up the test fixture before exercising it."
-        pass
-
-    def tearDown(self):
-        "Hook method for deconstructing the test fixture after testing it."
-        pass
-
-    def countTestCases(self):
-        return 1
-
-    def defaultTestResult(self):
-        return TestResult()
-
-    def shortDescription(self):
-        """Returns a one-line description of the test, or None if no
-        description has been provided.
-
-        The default implementation of this method returns the first line of
-        the specified test method's docstring.
-        """
-        doc = self.__testMethodDoc
-        return doc and string.strip(string.split(doc, "\n")[0]) or None
-
-    def id(self):
-        return "%s.%s" % (self.__class__, self.__testMethodName)
-
-    def __str__(self):
-        return "%s (%s)" % (self.__testMethodName, self.__class__)
-
-    def __repr__(self):
-        return "<%s testMethod=%s>" % \
-               (self.__class__, self.__testMethodName)
-
-    def run(self, result=None):
-        return self(result)
-
-    def __call__(self, result=None):
-        if result is None: result = self.defaultTestResult()
-        result.startTest(self)
-        testMethod = getattr(self, self.__testMethodName)
-        try:
-            try:
-                self.setUp()
-            except KeyboardInterrupt:
-                raise
-            except:
-                result.addError(self, self.__exc_info())
-                return
-
-            ok = 0
-            try:
-                testMethod()
-                ok = 1
-            except self.failureException, e:
-                result.addFailure(self, self.__exc_info())
-            except KeyboardInterrupt:
-                raise
-            except:
-                result.addError(self, self.__exc_info())
-
-            try:
-                self.tearDown()
-            except KeyboardInterrupt:
-                raise
-            except:
-                result.addError(self, self.__exc_info())
-                ok = 0
-            if ok: result.addSuccess(self)
-        finally:
-            result.stopTest(self)
-
-    def debug(self):
-        """Run the test without collecting errors in a TestResult"""
-        self.setUp()
-        getattr(self, self.__testMethodName)()
-        self.tearDown()
-
-    def __exc_info(self):
-        """Return a version of sys.exc_info() with the traceback frame
-           minimised; usually the top level of the traceback frame is not
-           needed.
-        """
-        exctype, excvalue, tb = sys.exc_info()
-        if sys.platform[:4] == 'java': ## tracebacks look different in Jython
-            return (exctype, excvalue, tb)
-        newtb = tb.tb_next
-        if newtb is None:
-            return (exctype, excvalue, tb)
-        return (exctype, excvalue, newtb)
-
-    def fail(self, msg=None):
-        """Fail immediately, with the given message."""
-        raise self.failureException, msg
-
-    def failIf(self, expr, msg=None):
-        "Fail the test if the expression is true."
-        if expr: raise self.failureException, msg
-
-    def failUnless(self, expr, msg=None):
-        """Fail the test unless the expression is true."""
-        if not expr: raise self.failureException, msg
-
-    def failUnlessRaises(self, excClass, callableObj, *args, **kwargs):
-        """Fail unless an exception of class excClass is thrown
-           by callableObj when invoked with arguments args and keyword
-           arguments kwargs. If a different type of exception is
-           thrown, it will not be caught, and the test case will be
-           deemed to have suffered an error, exactly as for an
-           unexpected exception.
-        """
-        try:
-            apply(callableObj, args, kwargs)
-        except excClass:
-            return
-        else:
-            if hasattr(excClass,'__name__'): excName = excClass.__name__
-            else: excName = str(excClass)
-            raise self.failureException, excName
-
-    def failUnlessEqual(self, first, second, msg=None):
-        """Fail if the two objects are unequal as determined by the '!='
-           operator.
-        """
-        if first != second:
-            raise self.failureException, \
-                  (msg or '%s != %s' % (`first`, `second`))
-
-    def failIfEqual(self, first, second, msg=None):
-        """Fail if the two objects are equal as determined by the '=='
-           operator.
-        """
-        if first == second:
-            raise self.failureException, \
-                  (msg or '%s == %s' % (`first`, `second`))
-
-    assertEqual = assertEquals = failUnlessEqual
-
-    assertNotEqual = assertNotEquals = failIfEqual
-
-    assertRaises = failUnlessRaises
-
-    assert_ = failUnless
-
-
-
-class TestSuite:
-    """A test suite is a composite test consisting of a number of TestCases.
-
-    For use, create an instance of TestSuite, then add test case instances.
-    When all tests have been added, the suite can be passed to a test
-    runner, such as TextTestRunner. It will run the individual test cases
-    in the order in which they were added, aggregating the results. When
-    subclassing, do not forget to call the base class constructor.
-    """
-    def __init__(self, tests=()):
-        self._tests = []
-        self.addTests(tests)
-
-    def __repr__(self):
-        return "<%s tests=%s>" % (self.__class__, self._tests)
-
-    __str__ = __repr__
-
-    def countTestCases(self):
-        cases = 0
-        for test in self._tests:
-            cases = cases + test.countTestCases()
-        return cases
-
-    def addTest(self, test):
-        self._tests.append(test)
-
-    def addTests(self, tests):
-        for test in tests:
-            self.addTest(test)
-
-    def run(self, result):
-        return self(result)
-
-    def __call__(self, result):
-        for test in self._tests:
-            if result.shouldStop:
-                break
-            test(result)
-        return result
-
-    def debug(self):
-        """Run the tests without collecting errors in a TestResult"""
-        for test in self._tests: test.debug()
-
-
-class FunctionTestCase(TestCase):
-    """A test case that wraps a test function.
-
-    This is useful for slipping pre-existing test functions into the
-    PyUnit framework. Optionally, set-up and tidy-up functions can be
-    supplied. As with TestCase, the tidy-up ('tearDown') function will
-    always be called if the set-up ('setUp') function ran successfully.
-    """
-
-    def __init__(self, testFunc, setUp=None, tearDown=None,
-                 description=None):
-        TestCase.__init__(self)
-        self.__setUpFunc = setUp
-        self.__tearDownFunc = tearDown
-        self.__testFunc = testFunc
-        self.__description = description
-
-    def setUp(self):
-        if self.__setUpFunc is not None:
-            self.__setUpFunc()
-
-    def tearDown(self):
-        if self.__tearDownFunc is not None:
-            self.__tearDownFunc()
-
-    def runTest(self):
-        self.__testFunc()
-
-    def id(self):
-        return self.__testFunc.__name__
-
-    def __str__(self):
-        return "%s (%s)" % (self.__class__, self.__testFunc.__name__)
-
-    def __repr__(self):
-        return "<%s testFunc=%s>" % (self.__class__, self.__testFunc)
-
-    def shortDescription(self):
-        if self.__description is not None: return self.__description
-        doc = self.__testFunc.__doc__
-        return doc and string.strip(string.split(doc, "\n")[0]) or None
-
-
-
-##############################################################################
-# Locating and loading tests
-##############################################################################
-
-class TestLoader:
-    """This class is responsible for loading tests according to various
-    criteria and returning them wrapped in a Test
-    """
-    testMethodPrefix = 'test'
-    sortTestMethodsUsing = cmp
-    suiteClass = TestSuite
-
-    def loadTestsFromTestCase(self, testCaseClass):
-        """Return a suite of all tests cases contained in testCaseClass"""
-        return self.suiteClass(map(testCaseClass,
-                                   self.getTestCaseNames(testCaseClass)))
-
-    def loadTestsFromModule(self, module):
-        """Return a suite of all tests cases contained in the given module"""
-        tests = []
-        for name in dir(module):
-            obj = getattr(module, name)
-            if type(obj) == types.ClassType and issubclass(obj, TestCase):
-                tests.append(self.loadTestsFromTestCase(obj))
-        return self.suiteClass(tests)
-
-    def loadTestsFromName(self, name, module=None):
-        """Return a suite of all tests cases given a string specifier.
-
-        The name may resolve either to a module, a test case class, a
-        test method within a test case class, or a callable object which
-        returns a TestCase or TestSuite instance.
-
-        The method optionally resolves the names relative to a given module.
-        """
-        parts = string.split(name, '.')
-        if module is None:
-            if not parts:
-                raise ValueError, "incomplete test name: %s" % name
-            else:
-                parts_copy = parts[:]
-                while parts_copy:
-                    try:
-                        module = __import__(string.join(parts_copy,'.'))
-                        break
-                    except ImportError:
-                        del parts_copy[-1]
-                        if not parts_copy: raise
-                parts = parts[1:]
-        obj = module
-        for part in parts:
-            obj = getattr(obj, part)
-
-        import unittest
-        if type(obj) == types.ModuleType:
-            return self.loadTestsFromModule(obj)
-        elif type(obj) == types.ClassType and issubclass(obj, unittest.TestCase):
-            return self.loadTestsFromTestCase(obj)
-        elif type(obj) == types.UnboundMethodType:
-            return obj.im_class(obj.__name__)
-        elif callable(obj):
-            test = obj()
-            if not isinstance(test, unittest.TestCase) and \
-               not isinstance(test, unittest.TestSuite):
-                raise ValueError, \
-                      "calling %s returned %s, not a test" % (obj,test)
-            return test
-        else:
-            raise ValueError, "don't know how to make test from: %s" % obj
-
-    def loadTestsFromNames(self, names, module=None):
-        """Return a suite of all tests cases found using the given sequence
-        of string specifiers. See 'loadTestsFromName()'.
-        """
-        suites = []
-        for name in names:
-            suites.append(self.loadTestsFromName(name, module))
-        return self.suiteClass(suites)
-
-    def getTestCaseNames(self, testCaseClass):
-        """Return a sorted sequence of method names found within testCaseClass
-        """
-        testFnNames = filter(lambda n,p=self.testMethodPrefix: n[:len(p)] == p,
-                             dir(testCaseClass))
-        for baseclass in testCaseClass.__bases__:
-            for testFnName in self.getTestCaseNames(baseclass):
-                if testFnName not in testFnNames:  # handle overridden methods
-                    testFnNames.append(testFnName)
-        if self.sortTestMethodsUsing:
-            testFnNames.sort(self.sortTestMethodsUsing)
-        return testFnNames
-
-
-
-defaultTestLoader = TestLoader()
-
-
-##############################################################################
-# Patches for old functions: these functions should be considered obsolete
-##############################################################################
-
-def _makeLoader(prefix, sortUsing, suiteClass=None):
-    loader = TestLoader()
-    loader.sortTestMethodsUsing = sortUsing
-    loader.testMethodPrefix = prefix
-    if suiteClass: loader.suiteClass = suiteClass
-    return loader
-
-def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp):
-    return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass)
-
-def makeSuite(testCaseClass, prefix='test', sortUsing=cmp, suiteClass=TestSuite):
-    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(testCaseClass)
-
-def findTestCases(module, prefix='test', sortUsing=cmp, suiteClass=TestSuite):
-    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module)
-
-
-##############################################################################
-# Text UI
-##############################################################################
-
-class _WritelnDecorator:
-    """Used to decorate file-like objects with a handy 'writeln' method"""
-    def __init__(self,stream):
-        self.stream = stream
-
-    def __getattr__(self, attr):
-        return getattr(self.stream,attr)
-
-    def writeln(self, *args):
-        if args: apply(self.write, args)
-        self.write('\n') # text-mode streams translate to \r\n if needed
-
-
-class _TextTestResult(TestResult):
-    """A test result class that can print formatted text results to a stream.
-
-    Used by TextTestRunner.
-    """
-    separator1 = '=' * 70
-    separator2 = '-' * 70
-
-    def __init__(self, stream, descriptions, verbosity):
-        TestResult.__init__(self)
-        self.stream = stream
-        self.showAll = verbosity > 1
-        self.dots = verbosity == 1
-        self.descriptions = descriptions
-
-    def getDescription(self, test):
-        if self.descriptions:
-            return test.shortDescription() or str(test)
-        else:
-            return str(test)
-
-    def startTest(self, test):
-        TestResult.startTest(self, test)
-        if self.showAll:
-            self.stream.write(self.getDescription(test))
-            self.stream.write(" ... ")
-
-    def addSuccess(self, test):
-        TestResult.addSuccess(self, test)
-        if self.showAll:
-            self.stream.writeln("ok")
-        elif self.dots:
-            self.stream.write('.')
-
-    def addError(self, test, err):
-        TestResult.addError(self, test, err)
-        if self.showAll:
-            self.stream.writeln("ERROR")
-        elif self.dots:
-            self.stream.write('E')
-
-    def addFailure(self, test, err):
-        TestResult.addFailure(self, test, err)
-        if self.showAll:
-            self.stream.writeln("FAIL")
-        elif self.dots:
-            self.stream.write('F')
-
-    def printErrors(self):
-        if self.dots or self.showAll:
-            self.stream.writeln()
-        self.printErrorList('ERROR', self.errors)
-        self.printErrorList('FAIL', self.failures)
-
-    def printErrorList(self, flavour, errors):
-        for test, err in errors:
-            self.stream.writeln(self.separator1)
-            self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
-            self.stream.writeln(self.separator2)
-            self.stream.writeln("%s" % err)
-
-
-class TextTestRunner:
-    """A test runner class that displays results in textual form.
-
-    It prints out the names of tests as they are run, errors as they
-    occur, and a summary of the results at the end of the test run.
-    """
-    def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1):
-        self.stream = _WritelnDecorator(stream)
-        self.descriptions = descriptions
-        self.verbosity = verbosity
-
-    def _makeResult(self):
-        return _TextTestResult(self.stream, self.descriptions, self.verbosity)
-
-    def run(self, test):
-        "Run the given test case or test suite."
-        result = self._makeResult()
-        startTime = time.time()
-        test(result)
-        stopTime = time.time()
-        timeTaken = float(stopTime - startTime)
-        result.printErrors()
-        self.stream.writeln(result.separator2)
-        run = result.testsRun
-        self.stream.writeln("Ran %d test%s in %.3fs" %
-                            (run, run != 1 and "s" or "", timeTaken))
-        self.stream.writeln()
-        if not result.wasSuccessful():
-            self.stream.write("FAILED (")
-            failed, errored = map(len, (result.failures, result.errors))
-            if failed:
-                self.stream.write("failures=%d" % failed)
-            if errored:
-                if failed: self.stream.write(", ")
-                self.stream.write("errors=%d" % errored)
-            self.stream.writeln(")")
-        else:
-            self.stream.writeln("OK")
-        return result
-
-
-
-##############################################################################
-# Facilities for running tests from the command line
-##############################################################################
-
-class TestProgram:
-    """A command-line program that runs a set of tests; this is primarily
-       for making test modules conveniently executable.
-    """
-    USAGE = """\
-Usage: %(progName)s [options] [test] [...]
-
-Options:
-  -h, --help       Show this message
-  -v, --verbose    Verbose output
-  -q, --quiet      Minimal output
-
-Examples:
-  %(progName)s                               - run default set of tests
-  %(progName)s MyTestSuite                   - run suite 'MyTestSuite'
-  %(progName)s MyTestCase.testSomething      - run MyTestCase.testSomething
-  %(progName)s MyTestCase                    - run all 'test*' test methods
-                                               in MyTestCase
-"""
-    def __init__(self, module='__main__', defaultTest=None,
-                 argv=None, testRunner=None, testLoader=defaultTestLoader):
-        if type(module) == type(''):
-            self.module = __import__(module)
-            for part in string.split(module,'.')[1:]:
-                self.module = getattr(self.module, part)
-        else:
-            self.module = module
-        if argv is None:
-            argv = sys.argv
-        self.verbosity = 1
-        self.defaultTest = defaultTest
-        self.testRunner = testRunner
-        self.testLoader = testLoader
-        self.progName = os.path.basename(argv[0])
-        self.parseArgs(argv)
-        self.runTests()
-
-    def usageExit(self, msg=None):
-        if msg: print msg
-        print self.USAGE % self.__dict__
-        sys.exit(2)
-
-    def parseArgs(self, argv):
-        import getopt
-        try:
-            options, args = getopt.getopt(argv[1:], 'hHvq',
-                                          ['help','verbose','quiet'])
-            for opt, value in options:
-                if opt in ('-h','-H','--help'):
-                    self.usageExit()
-                if opt in ('-q','--quiet'):
-                    self.verbosity = 0
-                if opt in ('-v','--verbose'):
-                    self.verbosity = 2
-            if len(args) == 0 and self.defaultTest is None:
-                self.test = self.testLoader.loadTestsFromModule(self.module)
-                return
-            if len(args) > 0:
-                self.testNames = args
-            else:
-                self.testNames = (self.defaultTest,)
-            self.createTests()
-        except getopt.error, msg:
-            self.usageExit(msg)
-
-    def createTests(self):
-        self.test = self.testLoader.loadTestsFromNames(self.testNames,
-                                                       self.module)
-
-    def runTests(self):
-        if self.testRunner is None:
-            self.testRunner = TextTestRunner(verbosity=self.verbosity)
-        result = self.testRunner.run(self.test)
-        sys.exit(not result.wasSuccessful())
-
-main = TestProgram
-
-
-##############################################################################
-# Executing this module from the command line
-##############################################################################
-
-if __name__ == "__main__":
-    main(module=None)
--- a/tests/utils.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tests/utils.py	Wed Sep 03 16:18:43 2008 +0000
@@ -2,7 +2,7 @@
 """
 import sys, os, string, fnmatch, copy, re
 from ConfigParser import ConfigParser
-from reportlab.test import unittest
+import unittest
 
 # Helper functions.
 def isWritable(D):
@@ -278,7 +278,6 @@
                     raise AssertionError("%s not near %s" % (a, b))
     assertNear = staticmethod(assertNear)
 
-
 class ScriptThatMakesFileTest(unittest.TestCase):
     """Runs a Python script at OS level, expecting it to produce a file.
 
@@ -292,16 +291,13 @@
         unittest.TestCase.__init__(self)
 
     def setUp(self):
+        self.cwd = os.getcwd()
+        from tests.utils import testsFolder
+        scriptDir=self.scriptDir
+        if not os.path.isabs(scriptDir):
+            scriptDir=os.path.join(testsFolder,scriptDir)
 
-        self.cwd = os.getcwd()
-        #change to reportlab directory first, so that
-        #relative paths may be given to scriptdir
-        import reportlab
-        self.rl_dir = os.path.dirname(reportlab.__file__)
-        self.fn = __file__
-        os.chdir(self.rl_dir)
-
-        os.chdir(self.scriptDir)
+        os.chdir(scriptDir)
         assert os.path.isfile(self.scriptName), "Script %s not found!" % self.scriptName
         if os.path.isfile(self.outFileName):
             os.remove(self.outFileName)
@@ -317,3 +313,14 @@
             print out
         status = p.close()
         assert os.path.isfile(self.outFileName), "File %s not created!" % self.outFileName
+
+import tests as testsFolder
+testsFolder=testsFolder.__path__[0]
+if not os.path.isabs(testsFolder): testsFolder=os.path.normpath(os.path.abspath(testsFolder))
+RL_HOME=os.path.join(testsFolder,'src','reportlab')
+if not os.path.isdir(RL_HOME):
+    RL_HOME=os.path.join(testsFolder,'reportlab')
+if not os.path.isdir(RL_HOME):
+    import reportlab as RL_HOME
+    RL_HOME=RL_HOME.__path__[0]
+    if not os.path.isabs(RL_HOME): RL_HOME=os.path.normpath(os.path.abspath(RL_HOME))
--- a/tools/docco/graphdocpy.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tools/docco/graphdocpy.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,19 +1,13 @@
 #!/usr/bin/env python
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2008
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/tools/docco/graphdocpy.py
-
 """Generate documentation for reportlab.graphics classes.
-
 Type the following for usage info:
 
   python graphdocpy.py -h
 """
-
-
 __version__ = '0.8'
 
-
 import sys
 sys.path.insert(0, '.')
 import os, re, types, string, getopt, pickle, copy, time, pprint, traceback
@@ -962,9 +956,12 @@
         print "Saved %s." % builder.outPath
 
     #if doing the usual, put a copy in docs
-    if builder.outPath == 'reportlab.graphics.pdf':
-        import shutil, reportlab
-        dst = os.path.join(os.path.dirname(reportlab.__file__),'docs','graphics_reference.pdf')
+    if builder.outPath=='reportlab.graphics.pdf':
+        import shutil, tools
+        topDir=tools.__path__[0]
+        if not os.path.isabs(topDir): topDir=os.path.abspath(topDir)
+        topDir=os.path.dirname(topDir)
+        dst = os.path.join(topDir,'docs','graphics_reference.pdf')
         shutil.copyfile('reportlab.graphics.pdf', dst)
         if not isSilent:
             print 'copied to '+dst
--- a/tools/pythonpoint/pythonpoint.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tools/pythonpoint/pythonpoint.py	Wed Sep 03 16:18:43 2008 +0000
@@ -1,5 +1,4 @@
 #!/usr/bin/env python
-
 """
 This is PythonPoint!
 
@@ -116,11 +115,9 @@
 class FontNameNotFoundError(Exception):
     pass
 
-
 class FontFilesNotFoundError(Exception):
     pass
 
-
 ##def findFontName(path):
 ##    "Extract a Type-1 font name from an AFM file."
 ##
@@ -182,8 +179,6 @@
 ##    pdfmetrics.registerTypeFace(T1face)
 ##    T1font = pdfmetrics.Font(name, T1faceName, 'WinAnsiEncoding')
 ##    pdfmetrics.registerFont(T1font)
-
-
 def registerFont0(sourceFile, name, path):
     "Register Type-1 font for future use, simple version."
 
@@ -934,9 +929,12 @@
         return self.figure
 
 def getSampleStyleSheet():
-    from reportlab.tools.pythonpoint.styles.standard import getParagraphStyles
+    from tools.pythonpoint.styles.standard import getParagraphStyles
     return getParagraphStyles()
 
+def toolsDir():
+    import tools
+    return tools.__path__[0]
 
 #make a singleton and a function to access it
 _styles = None
@@ -959,10 +957,10 @@
             import pyRXP
         except ImportError:
             return
-        from reportlab.lib.utils import open_and_read, _RL_DIR, rl_isfile
+        from reportlab.lib.utils import open_and_read, rl_isfile
         dtd = 'pythonpoint.dtd'
         if not rl_isfile(dtd):
-            dtd = os.path.join(_RL_DIR,'tools','pythonpoint','pythonpoint.dtd')
+            dtd = os.path.join(toolsDir(),'pythonpoint','pythonpoint.dtd')
             if not rl_isfile(dtd): return
         def eocb(URI,dtdText=open_and_read(dtd),dtd=dtd):
             if os.path.basename(URI)=='pythonpoint.dtd': return dtd,dtdText
@@ -985,7 +983,7 @@
 
 def _process(rawdata, datafilename, notes=0, handout=0, printout=0, cols=0, verbose=0, outDir=None, fx=1):
     #print 'inner process fx=%d' % fx
-    from reportlab.tools.pythonpoint.stdparser import PPMLParser
+    from tools.pythonpoint.stdparser import PPMLParser
     parser = PPMLParser()
     parser.fx = fx
     parser.sourceFilename = datafilename
--- a/tools/pythonpoint/stdparser.py	Wed Sep 03 16:11:36 2008 +0000
+++ b/tools/pythonpoint/stdparser.py	Wed Sep 03 16:18:43 2008 +0000
@@ -13,25 +13,25 @@
 from reportlab.lib import colors
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 from reportlab.lib.utils import recursiveImport
-from reportlab.tools.pythonpoint import pythonpoint
+from tools.pythonpoint import pythonpoint
 from reportlab.platypus import figures
 
 
-def getModule(modulename,fromPath='reportlab.tools.pythonpoint.styles'):
+def getModule(modulename,fromPath='tools.pythonpoint.styles'):
     """Get a module containing style declarations.
 
     Search order is:
-        reportlab/tools/pythonpoint/
-        reportlab/tools/pythonpoint/styles/
+        tools/pythonpoint/
+        tools/pythonpoint/styles/
         ./
     """
 
     try:
-        exec 'from reportlab.tools.pythonpoint import '+modulename
+        exec 'from tools.pythonpoint import '+modulename
         return eval(modulename)
     except ImportError:
         try:
-            exec 'from reportlab.tools.pythonpoint.styles import '+modulename
+            exec 'from tools.pythonpoint.styles import '+modulename
             return eval(modulename)
         except ImportError:
             exec 'import '+modulename