Update of /cvsroot/pywin32/pywin32/adodbapi/tests
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30556/tests
Modified Files:
Tag: py3k
RunTests.bat adodbapitest.py adodbapitestconfig.py db_print.py
dbapi20.py test_adodbapi_dbapi20.py
Log Message:
Merge 2.2.2 changes and Test using Python 2.6
Index: adodbapitest.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitest.py,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** adodbapitest.py 20 Sep 2008 19:54:59 -0000 1.2.2.1
--- adodbapitest.py 13 Nov 2008 04:28:21 -0000 1.2.2.2
***************
*** 1,3 ****
! """ Unit tests for adodbapi"""
"""
adodbapi - A python DB API 2.0 interface to Microsoft ADO
--- 1,5 ----
! """ Unit tests for adodbapi version 2.2.3"""
! from __future__ import print_function
! from __future__ import unicode_literals
"""
adodbapi - A python DB API 2.0 interface to Microsoft ADO
***************
*** 32,38 ****
win32 = False
import adodbapi
- ## from adodbapi.tests
- import adodbapitestconfig
#adodbapi.adodbapi.verbose = 3
--- 34,39 ----
win32 = False
+ import adodbapitestconfig #will find (parent?) adodbpai
import adodbapi
#adodbapi.adodbapi.verbose = 3
***************
*** 253,257 ****
def testDataTypeChar(self):
for sqlDataType in ("char(6)","nchar(6)"):
! self.helpTestDataType(sqlDataType,'STRING','spam ',allowedReturnValues=['spam','spam','spam ','spam '])
def testDataTypeVarChar(self):
--- 254,258 ----
def testDataTypeChar(self):
for sqlDataType in ("char(6)","nchar(6)"):
! self.helpTestDataType(sqlDataType,'STRING','spam ',allowedReturnValues=['spam','spam '])
def testDataTypeVarChar(self):
***************
*** 264,268 ****
def testDataTypeDate(self):
#Does not work with pytonTimeConvertor
! #self.helpTestDataType("smalldatetime",'DATETIME',adodbapi.Timestamp(2002,10,28,12,15,00)) #Accuracy one minute
self.helpTestDataType("datetime",'DATETIME',adodbapi.Date(2002,10,28),compareAlmostEqual=True)
--- 265,269 ----
def testDataTypeDate(self):
#Does not work with pytonTimeConvertor
! #self.helpTestDataType("smalldatetime",'DATETIME',adodbapi.Timestamp(2002,10,28,12,15,0)) #Accuracy one minute
self.helpTestDataType("datetime",'DATETIME',adodbapi.Date(2002,10,28),compareAlmostEqual=True)
***************
*** 335,339 ****
crsr.execute("SELECT fldData FROM tblTemp")
if crsr.rowcount == -1:
! #print "provider does not support rowcount on select"
pass
else:
--- 336,340 ----
crsr.execute("SELECT fldData FROM tblTemp")
if crsr.rowcount == -1:
! #print("provider does not support rowcount on select")
pass
else:
***************
*** 437,451 ****
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'))
--- 438,462 ----
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: '!!This function returns a funny unicode string %s!!'%x
! self.helpTestDataType("numeric(18,2)",'NUMBER','3.45',
! allowedReturnValues=['!!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'))
***************
*** 627,631 ****
def testDateObjectFromCOMDate(self):
cmd=self.tc.DateObjectFromCOMDate(37435.7604282)
! t=mx.DateTime.DateTime(2002,6,28,18,15,00)
t2=mx.DateTime.DateTime(2002,6,28,18,15,2)
assert t2>cmd>t
--- 638,642 ----
def testDateObjectFromCOMDate(self):
cmd=self.tc.DateObjectFromCOMDate(37435.7604282)
! t=mx.DateTime.DateTime(2002,6,28,18,15,0)
t2=mx.DateTime.DateTime(2002,6,28,18,15,2)
assert t2>cmd>t
***************
*** 658,662 ****
t1=time.gmtime(time.mktime((2002,6,28,12,14,1, 4,31+28+31+30+31+28,-1)))
t2=time.gmtime(time.mktime((2002,6,28,12,16,1, 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):
--- 669,673 ----
t1=time.gmtime(time.mktime((2002,6,28,12,14,1, 4,31+28+31+30+31+28,-1)))
t2=time.gmtime(time.mktime((2002,6,28,12,16,1, 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):
***************
*** 727,734 ****
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)
--- 738,741 ----
Index: RunTests.bat
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/RunTests.bat,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1
*** RunTests.bat 4 Jan 2008 18:49:10 -0000 1.1.1.1
--- RunTests.bat 13 Nov 2008 04:28:21 -0000 1.1.1.1.2.1
***************
*** 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 p3k.bat adodbapitest.py
+ echo .
+ echo .
+ REM generic test
+ @echo .
+ call p3k.bat test_adodbapi_dbapi20.py
+ echo .
+ call p3k.bat db_print.py
+ echo .
pause Testing complete
Index: adodbapitestconfig.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitestconfig.py,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** adodbapitestconfig.py 20 Sep 2008 19:54:59 -0000 1.2.2.1
--- adodbapitestconfig.py 13 Nov 2008 04:28:21 -0000 1.2.2.2
***************
*** 1,5 ****
--- 1,24 ----
# Configure this in order to run the testcases.
+ "adodbapitestconfig.py v 2.2.3"
+ from __future__ import print_function
+ from __future__ import unicode_literals
+ 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
***************
*** 12,25 ****
except:
doMxDateTimeTest=False #Requires eGenixMXExtensions
! import sys
! if float(sys.version[:3])>2.29:
! doDateTimeTest=True #Requires Python 2.3 Alpha2
! else:
! doDateTimeTest=False
! print('Error: adodbapi 2.1 requires Python 2.3')
!
! iterateOverTimeTests=False #True
if doAccessTest:
--- 31,39 ----
except:
doMxDateTimeTest=False #Requires eGenixMXExtensions
+ doMySqlTest = False
+ doDateTimeTest=True
! iterateOverTimeTests=False
if doAccessTest:
***************
*** 69,78 ****
# 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:
s = adodbapi.connect(connStrSQLServer) #connect to server
--- 83,96 ----
# connStrAccess = "Driver={Microsoft Access Driver (*.mdb)};db=%s;Uid=;Pwd=;" + _accessdatasource
! if True: #needed for dbapi20 test
_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)
! if doSqlServerTest:
print(' ...Testing MS-SQL login...')
+
try:
s = adodbapi.connect(connStrSQLServer) #connect to server
***************
*** 85,92 ****
_computername='10.100.5.249'
_databasename='test'
!
! connStrMySql = 'Driver={MySQL ODBC 5.1 Driver};Server=%s;Port=3306;Database=%s;Option=3;' % \
! (_computername,_databasename)
print(' ...Testing MySql login...')
try:
s = adodbapi.connect(connStrMySql) #connect to server
--- 103,112 ----
_computername='10.100.5.249'
_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:
s = adodbapi.connect(connStrMySql) #connect to server
***************
*** 95,98 ****
print(inst.args[0][2]) # should be the error message
doMySqlTest = False
-
-
\ No newline at end of file
--- 115,116 ----
Index: dbapi20.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/dbapi20.py,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2
*** dbapi20.py 20 Sep 2008 19:54:59 -0000 1.1.1.1.2.1
--- dbapi20.py 13 Nov 2008 04:28:21 -0000 1.1.1.1.2.2
***************
*** 20,26 ****
# $Log$
# Revision 1.1.1.1.2.1 2008/09/20 19:54:59 rupole
# Include latest changes from main branch
! # Updates for py3k (should be reviewed by adodbapi maintainer)
#
# Revision 1.1.1.1 2008/01/04 18:49:10 kf7xm
--- 20,33 ----
# $Log$
+ # Revision 1.1.1.1.2.2 2008/11/13 04:28:21 kf7xm
+ # Merge 2.2.2 changes and Test using Python 2.6
+ #
+
# Revision 1.1.1.1.2.1 2008/09/20 19:54:59 rupole
# Include latest changes from main branch
! # Updates for py3k (reviewed by adodbapi maintainer) -- Done -- V.Cole
! #
! # Revision 1.2 2008/10/01 14:44:53 mhammond
! # Move to 'new style' exception raising.
#
# Revision 1.1.1.1 2008/01/04 18:49:10 kf7xm
Index: db_print.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/db_print.py,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2
*** db_print.py 20 Sep 2008 19:54:59 -0000 1.1.1.1.2.1
--- db_print.py 13 Nov 2008 04:28:21 -0000 1.1.1.1.2.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.1.1.1.2.1
diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1
*** test_adodbapi_dbapi20.py 4 Jan 2008 18:49:10 -0000 1.1.1.1
--- test_adodbapi_dbapi20.py 13 Nov 2008 04:28:21 -0000 1.1.1.1.2.1
***************
*** 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,9 ----
! from __future__ import print_function
! from __future__ import unicode_literals
! 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
|