[Zope-CVS] CVS: Products/AdaptableStorage/tests - testAll.py:1.4

Shane Hathaway shane@zope.com
Fri, 10 Jan 2003 11:08:26 -0500


Update of /cvs-repository/Products/AdaptableStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv14707/tests

Modified Files:
	testAll.py 
Log Message:
Moved toward SQL database independence.  Tried to port to Gadfly, but
Gadfly doesn't even support simple sequences, so it's not interesting
enough.  I'm checking in some of the changes anyway to simplify future
ports.

- Used a WHERE clause to limit the results of checking for table
existence rather than a LIMIT clause, since WHERE is more likely to be
supported everywhere.

- Changed the name of createMapper() to createPostgreSQLMapper().
Moved the creation of the connection to createPostgreSQLMapper(),
permitting reuse of createMapperPlus() by other databases.



=== Products/AdaptableStorage/tests/testAll.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/tests/testAll.py:1.3	Tue Dec 31 16:09:05 2002
+++ Products/AdaptableStorage/tests/testAll.py	Fri Jan 10 11:08:23 2003
@@ -16,7 +16,7 @@
 $Id$
 """
 
-import unittest
+import sys, unittest
 
 from testSerialization import SerializationTests
 from testInterfaceImpl import InterfaceImplTests
@@ -26,13 +26,21 @@
 try:
     import psycopg
 except ImportError:
-    pass
+    sys.stderr.write('Warning: could not import psycopg.\n')
+    sys.stderr.write('Not running the PostgreSQL tests.\n')
 else:
-    # Run the Postgres tests.
-    from Products.AdaptableStorage.gateway_sql.tests.testZope2SQL \
-         import Zope2SQLTests
-    from Products.AdaptableStorage.gateway_sql.tests.testInterfaceImpl \
-         import InterfaceImplTests as InterfaceImplTests2
+    try:
+        c = psycopg.connect('')
+        c.close()
+    except psycopg.DatabaseError:
+        sys.stderr.write('Warning: could not open a psycopg connection.\n')
+        sys.stderr.write('Not running the PostgreSQL tests.\n')
+    else:
+        # Run the PostgreSQL tests.
+        from Products.AdaptableStorage.gateway_sql.tests.testZope2SQL \
+             import Zope2SQLTests
+        from Products.AdaptableStorage.gateway_sql.tests.testInterfaceImpl \
+             import InterfaceImplTests as InterfaceImplTests2
 
 
 if __name__ == '__main__':