Update of /cvsroot/pywin32/pywin32/adodbapi/tests
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32365/tests
Modified Files:
RunTests.bat adodbapitest.py adodbapitestconfig.py db_print.py
test_adodbapi_dbapi20.py
Log Message:
Index: adodbapitest.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitest.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** adodbapitest.py 1 Oct 2008 14:44:53 -0000 1.5
--- adodbapitest.py 11 Nov 2008 23:54:30 -0000 1.6
***************
*** 1,3 ****
! """ Unit tests for adodbapi"""
"""
adodbapi - A python DB API 2.0 interface to Microsoft ADO
--- 1,3 ----
! """ Unit tests for adodbapi version 2.2.2"""
"""
adodbapi - A python DB API 2.0 interface to Microsoft ADO
***************
*** 32,37 ****
win32 = False
import adodbapi
- import adodbapitestconfig
#adodbapi.adodbapi.verbose = 3
--- 32,37 ----
win32 = False
+ import adodbapitestconfig #will find (parent?) adodbpai
import adodbapi
#adodbapi.adodbapi.verbose = 3
***************
*** 53,57 ****
def getConnection(self):
! raise Exception("This method must be overriden by a subclass")
def getCursor(self):
--- 53,57 ----
def getConnection(self):
! raise "This method must be overriden by a subclass"
def getCursor(self):
***************
*** 189,193 ****
assert descTuple[1] == adodbapi.ROWID, 'was "%s"'%descTuple[1]
else:
! raise Exception("DBAPIDataTypeString not provided")
#Test data binding
--- 189,193 ----
assert descTuple[1] == adodbapi.ROWID, 'was "%s"'%descTuple[1]
else:
! raise "DBAPIDataTypeString not provided"
#Test data binding
***************
*** 435,449 ****
def testUserDefinedConversionForExactNumericTypes(self):
# By default decimal and numbers are returned as decimals.
# Instead, make them return as floats
! oldconverter=adodbapi.variantConversions[adodbapi.adNumeric]
! adodbapi.variantConversions[adodbapi.adNumeric]=adodbapi.cvtFloat
self.helpTestDataType("decimal(18,2)",'NUMBER',3.45,compareAlmostEqual=1)
self.helpTestDataType("numeric(18,2)",'NUMBER',3.45,compareAlmostEqual=1)
! # now strings
! adodbapi.variantConversions[adodbapi.adNumeric]=adodbapi.cvtString
self.helpTestDataType("numeric(18,2)",'NUMBER','3.45')
! # now the way they were
! adodbapi.variantConversions[adodbapi.adNumeric]=oldconverter #Restore
self.helpTestDataType("numeric(18,2)",'NUMBER',decimal.Decimal('3.45'))
--- 435,459 ----
def testUserDefinedConversionForExactNumericTypes(self):
+ # variantConversions is a dictionary of convertion functions
+ # held internally in adodbapi
+
# By default decimal and numbers are returned as decimals.
# Instead, make them return as floats
!
! oldconverter = adodbapi.variantConversions[adodbapi.adNumeric] #keep old function to restore later
!
! adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtFloat
self.helpTestDataType("decimal(18,2)",'NUMBER',3.45,compareAlmostEqual=1)
self.helpTestDataType("numeric(18,2)",'NUMBER',3.45,compareAlmostEqual=1)
! # now return strings
! adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtString
self.helpTestDataType("numeric(18,2)",'NUMBER','3.45')
! # now a completly weird user defined convertion
! adodbapi.variantConversions[adodbapi.adNumeric] = lambda x: u'!!This function returns a funny unicode string %s!!'%x
! self.helpTestDataType("numeric(18,2)",'NUMBER','3.45',
! allowedReturnValues=[u'!!This function returns a funny unicode string 3.45!!'])
!
! # now reset the converter to its original function
! adodbapi.variantConversions[adodbapi.adNumeric]=oldconverter #Restore the original convertion function
self.helpTestDataType("numeric(18,2)",'NUMBER',decimal.Decimal('3.45'))
***************
*** 656,660 ****
t1=time.gmtime(time.mktime((2002,6,28,12,14,01, 4,31+28+31+30+31+28,-1)))
t2=time.gmtime(time.mktime((2002,6,28,12,16,01, 4,31+28+31+30+31+28,-1)))
! assert t1<cmd<t2,repr(cmd)+' should be about 2002-6-28 12:15:01'
def testDate(self):
--- 666,670 ----
t1=time.gmtime(time.mktime((2002,6,28,12,14,01, 4,31+28+31+30+31+28,-1)))
t2=time.gmtime(time.mktime((2002,6,28,12,16,01, 4,31+28+31+30+31+28,-1)))
! assert t1<cmd<t2, '"%s" should be about 2002-6-28 12:15:01'%repr(cmd)
def testDate(self):
***************
*** 725,732 ****
defaultDateConverter=adodbapi.dateconverter
print __doc__
- try:
- print adodbapi.version # show version
- except:
- print '"adodbapi.version()" not present or not working.'
print "Default Date Converter is %s" %(defaultDateConverter,)
unittest.TextTestRunner().run(suite)
--- 735,738 ----
Index: RunTests.bat
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/RunTests.bat,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** RunTests.bat 4 Jan 2008 18:49:10 -0000 1.1.1.1
--- RunTests.bat 11 Nov 2008 23:54:30 -0000 1.2
***************
*** 9,13 ****
echo .
REM generic test
! @echo . Note: one error is expected (no Warning class)
test_adodbapi_dbapi20.py
echo .
--- 9,13 ----
echo .
REM generic test
! @echo .
test_adodbapi_dbapi20.py
echo .
***************
*** 15,17 ****
--- 15,30 ----
db_print.py
echo .
+ del *.pyc
+ del *.pyo
+ del ..\adodbapi.pyc
+ echo .
+ call ipy.bat adodbapitest.py
+ echo .
+ echo .
+ REM generic test
+ @echo .
+ call ipy.bat test_adodbapi_dbapi20.py
+ echo .
+ call ipy.bat db_print.py
+ echo .
pause Testing complete
Index: adodbapitestconfig.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitestconfig.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** adodbapitestconfig.py 1 Oct 2008 14:44:53 -0000 1.4
--- adodbapitestconfig.py 11 Nov 2008 23:54:30 -0000 1.5
***************
*** 1,10 ****
# Configure this in order to run the testcases.
import adodbapi
! doAccessTest = True
! doSqlServerTest = False #True
! doMySqlTest = False #True
try: #If mx extensions are installed, use mxDateTime
import mx.DateTime
--- 1,25 ----
# Configure this in order to run the testcases.
+ "adodbapitestconfig.py v 2.2.2"
+ import os
+ import sys
+ print sys.version
+ #attempt to find adodbapi in this directory's parent
+ cwd = os.getcwd()
+ adoPath = os.path.normpath(cwd + '/../adodbapi.py')
+ if os.path.exists(adoPath):
+ if adoPath not in sys.path:
+ sys.path.insert(1,os.path.dirname(adoPath))
import adodbapi
+ # adodbapitest.py will import this same version when we return
! try:
! print adodbapi.version # show version
! except:
! print '"adodbapi.version" not present or not working.'
! print __doc__
+ doAccessTest = True
+ doSqlServerTest = True
try: #If mx extensions are installed, use mxDateTime
import mx.DateTime
***************
*** 12,16 ****
except:
doMxDateTimeTest=False #Requires eGenixMXExtensions
!
import sys
--- 27,32 ----
except:
doMxDateTimeTest=False #Requires eGenixMXExtensions
! doAS400Test = False
! doMySqlTest = False
import sys
***************
*** 21,77 ****
print 'Error: adodbapi 2.1 requires Python 2.3'
! iterateOverTimeTests=False #True
- if doAccessTest:
- _accessdatasource = None #set to None for automatic creation
- #r"C:\Program Files\Microsoft Office\Office\Samples\northwind.mdb;"
- #Typically C:\Program Files
- if _accessdatasource == None:
- # following setup code borrowed from pywin32 odbc test suite
- # kindly contributed by Frank Millman.
- import tempfile
- import os
- try:
- from win32com.client.gencache import EnsureDispatch
- from win32com.client import constants
- win32 = True
- except ImportError: #perhaps we are running IronPython
- win32 = False
- if not win32:
- from System import Activator, Type
- _accessdatasource = os.path.join(tempfile.gettempdir(), u"test_odbc.mdb")
- if os.path.isfile(_accessdatasource):
- os.unlink(_accessdatasource)
- # Create a brand-new database - what is the story with these?
- for suffix in (".36", ".35", ".30"):
- try:
- if win32:
- dbe = EnsureDispatch("DAO.DBEngine" + suffix)
- else:
- type= Type.GetTypeFromProgID("DAO.DBEngine" + suffix)
- dbe = Activator.CreateInstance(type)
- break
- except:
- pass
- else:
- raise RuntimeError("Can't find a DB engine")
- print ' ...Creating ACCESS db at',_accessdatasource
- if win32:
- workspace = dbe.Workspaces(0)
- newdb = workspace.CreateDatabase(_accessdatasource,
- constants.dbLangGeneral,
- constants.dbEncrypt)
- else:
- newdb = dbe.CreateDatabase(_accessdatasource,';LANGID=0x0409;CP=1252;COUNTRY=0')
- newdb.Close()
- connStrAccess = r"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _accessdatasource
- # for ODBC connection try...
- # connStrAccess = "Driver={Microsoft Access Driver (*.mdb)};db=%s;Uid=;Pwd=;" + _accessdatasource
if doSqlServerTest:
_computername="franklin" #or name of computer with SQL Server
_databasename="Northwind" #or something else
#connStrSQLServer = r"Provider=SQLOLEDB.1; Integrated Security=SSPI; Initial Catalog=%s;Data Source=%s" %(_databasename, _computername)
! connStrSQLServer = r"Provider=SQLOLEDB.1; User ID=guest; Password=xxxxx; Initial Catalog=%s;Data Source=%s" %(_databasename, _computername)
print ' ...Testing MS-SQL login...'
try:
--- 37,50 ----
print 'Error: adodbapi 2.1 requires Python 2.3'
! iterateOverTimeTests=False
if doSqlServerTest:
_computername="franklin" #or name of computer with SQL Server
_databasename="Northwind" #or something else
+ _username="guest"
+ _password="12345678"
#connStrSQLServer = r"Provider=SQLOLEDB.1; Integrated Security=SSPI; Initial Catalog=%s;Data Source=%s" %(_databasename, _computername)
! connStrSQLServer = r"Provider=SQLOLEDB.1; User ID=%s; Password=%s; Initial Catalog=%s;Data Source=%s" %(_username,_password,_databasename, _computername)
print ' ...Testing MS-SQL login...'
try:
***************
*** 86,91 ****
_databasename='test'
! connStrMySql = 'Driver={MySQL ODBC 5.1 Driver};Server=%s;Port=3306;Database=%s;Option=3;' % \
! (_computername,_databasename)
print ' ...Testing MySql login...'
try:
--- 59,66 ----
_databasename='test'
! #_driver="MySQL ODBC 3.51 Driver"
! _driver="MySQL ODBC 5.1 Driver"
! connStrMySql = 'Driver={%s};Server=%s;Port=3306;Database=%s;Option=3;' % \
! (_driver,_computername,_databasename)
print ' ...Testing MySql login...'
try:
***************
*** 96,98 ****
doMySqlTest = False
!
\ No newline at end of file
--- 71,91 ----
doMySqlTest = False
! if doAS400Test:
! #OLE DB -> "PROVIDER=IBMDA400; DATA SOURCE=MY_SYSTEM_NAME;USER ID=myUserName;PASSWORD=myPwd;DEFAULT COLLECTION=MY_LIBRARY;"
! connStrAS400skl = "Provider=IBMDA400; DATA SOURCE=%s;DEFAULT COLLECTION=%s;User ID=%s;Password=%s"
! # NOTE! user's PC must have OLE support installed in IBM Client Access Express
! _computername='SPICE'
! _databasename="DPVERNON"
! _username = 'DNTWCI'
! # or raw_input(' AS400 User ID for data retrieval [%s]:' % defaultUser)
! _password = 'DNTWCI'
! # or getpass.getpass(' AS400 password:') #read the password
! connStrAS400 = connStrAS400skl % (_computername,_databasename,_username,_password) #build the connection string
! print ' ...Testing AS400 login...'
! try:
! s = adodbapi.connect(connStrAS400) #connect to server
! s.close()
! except adodbapi.DatabaseError, inst:
! print inst.args[0][2] # should be the AS400 error message
! doAS400Test = False
!
\ No newline at end of file
Index: db_print.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/db_print.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** db_print.py 4 Jan 2008 18:49:10 -0000 1.1.1.1
--- db_print.py 11 Nov 2008 23:54:30 -0000 1.2
***************
*** 7,11 ****
_databasename="Northwind" #or something else
_username="guest"
! _password='xxxxx'
_table_name= 'Products'
--- 7,11 ----
_databasename="Northwind" #or something else
_username="guest"
! _password='12345678'
_table_name= 'Products'
Index: test_adodbapi_dbapi20.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/test_adodbapi_dbapi20.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** test_adodbapi_dbapi20.py 4 Jan 2008 18:49:10 -0000 1.1.1.1
--- test_adodbapi_dbapi20.py 11 Nov 2008 23:54:30 -0000 1.2
***************
*** 1,7 ****
print "This module depends on the dbapi20 compliance tests created by Stuart Bishop"
print "(see db-sig mailing list history for info)"
- print "Tested with dbapi20 version 1.8"
import dbapi20
import unittest
import popen2
--- 1,7 ----
print "This module depends on the dbapi20 compliance tests created by Stuart Bishop"
print "(see db-sig mailing list history for info)"
import dbapi20
+ print "Tested with dbapi20 %s" % dbapi20.__version__
import unittest
import popen2
|