[Python-checkins] python/dist/src/Lib/bsddb/test test_associate.py, 1.7, 1.8

greg at users.sourceforge.net greg at users.sourceforge.net
Mon Jun 28 00:06:52 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/bsddb/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11608/Lib/bsddb/test
Modified Files:
	test_associate.py 
Log Message:
Adds support for DB.pget and DBCursor.pget methods.
Based on a patch supplied by Ian Ward <ian at arevco.ca> on the pybsddb
mailing list 2004年03月26日.
Index: test_associate.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/test/test_associate.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_associate.py	12 Feb 2004 17:35:08 -0000	1.7
--- test_associate.py	28 Jun 2004 04:06:49 -0000	1.8
***************
*** 84,87 ****
--- 84,88 ----
 53: ("David Lanz", "Heartsounds", "New Age"),
 54: ("David Lanz", "Leaves on the Seine", "New Age"),
+ 99: ("unknown artist", "Unnamed song", "Unknown"),
 }
 
***************
*** 118,121 ****
--- 119,123 ----
 def createDB(self):
 self.primary = db.DB(self.env)
+ self.primary.set_get_returns_none(2)
 self.primary.open(self.filename, "primary", self.dbtype,
 db.DB_CREATE | db.DB_THREAD)
***************
*** 137,140 ****
--- 139,143 ----
 secDB = db.DB(self.env)
 secDB.set_flags(db.DB_DUP)
+ secDB.set_get_returns_none(2)
 secDB.open(self.filename, "secondary", db.DB_BTREE,
 db.DB_CREATE | db.DB_THREAD)
***************
*** 167,170 ****
--- 170,183 ----
 
 def finish_test(self, secDB):
+ # 'Blues' should not be in the secondary database
+ vals = secDB.pget('Blues')
+ assert vals == None, vals
+ 
+ vals = secDB.pget('Unknown')
+ assert vals[0] == 99 or vals[0] == '99', vals
+ vals[1].index('Unknown')
+ vals[1].index('Unnamed')
+ vals[1].index('unknown')
+ 
 if verbose:
 print "Primary key traversal:"
***************
*** 188,191 ****
--- 201,216 ----
 c = secDB.cursor()
 count = 0
+ 
+ # test cursor pget
+ vals = c.pget('Unknown', flags=db.DB_LAST)
+ assert vals[1] == 99 or vals[1] == '99', vals
+ assert vals[0] == 'Unknown'
+ vals[2].index('Unknown')
+ vals[2].index('Unnamed')
+ vals[2].index('unknown')
+ 
+ vals = c.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
+ assert vals == None, vals
+ 
 rec = c.first()
 assert rec[0] == "Jazz"


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /