[DB-SIG] DB API 2.0 Anal Compliance Unit Test for review

Stuart Bishop zen@shangri-la.dropbear.id.au
Thu, 13 Feb 2003 11:25:38 +1100


I've put together a DB API 2.0 compliance test case, currently weighing 
in at 586 lines. It tests all behaviour described in the spec, except 
for the newer 'Optional Additions' section (which may be added in the 
future). I'd like to get this right so I can enforce compliance in 
Gadfly, and would be happy for this testcase to end up in the SIG area 
on www.python.org.

http://stuartbishop.net/Software/DBAPI20TestSuite/

I'd appreciate driver maintainers to run this against their 
distributions and see what happens. I'm expecting that most drivers 
will fail one or more of the tests due to obscure cases. Where these 
failures occur, I think it would be appropriate to discuss it in this 
forum - if it is decided that the driver isn't broken I either need to 
fix the test suite or we need to fix the spec.

Here is the  psycopg stub that I used to test out the suite, so people 
can see that it should
only take a few minutes to put together their own RDBMS specific stub 
to run the tests:

import dbapi20
import unittest
import psycopg
import popen2

class test_Psycopg(dbapi20.test_DBAPI20,unittest.TestCase):
     driver = psycopg
     connect_args = ()
     connect_kw_args = {'dsn': 'dbname=dbapi20_test'}

     def setUp(self):
         # Call superclass setUp In case this does something in the
         # future
         dbapi20.test_DBAPI20.setUp(self)

         try:
             con = self._connect()
             con.close()
         except:
             cmd = "psql -c 'create database dbapi20_test'"
             cout,cin = popen2.popen2(cmd)
             cin.close()
             cout.read()

     def tearDown(self):
         dbapi20.test_DBAPI20.tearDown(self)

     # Some tests cannot be tested in a platform independant way - skip 
these for now.
     def test_nextset(self): pass
     def test_callproc(self): pass
     def test_setoutputsize(self): pass

if __name__ == '__main__':
     unittest.main()

-- 
Stuart Bishop <zen@shangri-la.dropbear.id.au>
http://shangri-la.dropbear.id.au/