[Zodb-checkins] CVS: StandaloneZODB - test.py:1.4

Jeremy Hylton jeremy@zope.com
Thu, 23 Aug 2001 20:35:19 -0400


Update of /cvs-repository/StandaloneZODB
In directory cvs.zope.org:/tmp/cvs-serv24352

Modified Files:
	test.py 
Log Message:
Remove Python-2.x-isms so that tests run with Python 1.5.2

Add a doc string that explains some of the issues involved in running
the tests under Python 1.5.2.


=== StandaloneZODB/test.py 1.3 => 1.4 ===
+
+The test harness was written for Python 2.1 and requires some
+hand-holding to use with Python 1.5.2.  The tests require:
+
+  1) a recent version of unittest, which can be downloaded from 
+     pyunit.sourceforge.net;
+     
+  2) distutils, which can be downloaded from
+     www.python.org/sigs/distutils-sig/;
+
+  and, if the ZEO tests are to be run,
+
+  3) a built version of Zope 2.3, which provides up-to-date versions
+     of asyncore and cPickle.
+
+There are some complications, however, because the StandaloneZODB
+includes code from Zope 2.4, which requires Python 2.1.  If the Zope
+top-level directory and lib/python directories are added to the path,
+the BTrees tests will fail, because they pick up an old version of the
+Interface module.  But the ZEO tests won't run *without* Zope on the
+path.  So it's one or the other.
+"""
+
 import os
 import re
+import string
 import sys
 import unittest
 from distutils.util import get_platform
@@ -23,15 +48,15 @@
         self.files = []
 
     def visit(self, rx, dir, files):
-        if dir.startswith(DOTSLASH + "build"):
+        if dir[:7] == DOTSLASH + "build":
             return
-        if not dir.endswith("tests"):
+        if dir[-5:] != "tests":
             return
         # XXX special case bsddb3Storage
-        if dir.startswith(DOTSLASH + "bsddb3Storage/bsddb3Storage"):
+        if dir[:29] == DOTSLASH + "bsddb3Storage/bsddb3Storage":
             dir = "./" + dir[16:]
         for file in files:
-            if file.startswith("test") and file.endswith(".py"):
+            if file[:4] == "test" and file[-3:] == ".py":
                 path = os.path.join(dir, file)
                 if rx is not None:
                     if rx.search(path):
@@ -47,7 +72,7 @@
 
 def package_import(modname):
     mod = __import__(modname)
-    for part in modname.split(".")[1:]:
+    for part in string.split(modname, ".")[1:]:
         mod = getattr(mod, part)
     return mod
 
@@ -61,10 +86,10 @@
 
     runner = unittest.TextTestRunner(verbosity=VERBOSE)
     for file in files:
-        assert file.startswith(DOTSLASH)
-        assert file.endswith('.py')
+        assert file[:2] == DOTSLASH
+        assert file[-3:] == '.py'
         modname = file[2:-3]
-        modname = modname.replace(os.sep, '.')
+        modname = string.replace(modname, os.sep, '.')
         mod = package_import(modname)
         try:
             suite = mod.test_suite()
@@ -77,13 +102,13 @@
 if __name__ == "__main__":
     import getopt
 
-    filter = None
+    filter = '.'
     VERBOSE = 0
 
     opts, args = getopt.getopt(sys.argv[1:], 'v')
     for k, v in opts:
         if k == '-v':
-            VERBOSE += 1
+            VERBOSE = VERBOSE + 1
     if args:
         filter = args[0]
     main(filter)