Mercurial > cpython-lru_cache-weakref
annotate Lib/bsddb/test/test_associate.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 81a1a1545172 |
| children | 96a241d4a0ab |
| rev | line source |
|---|---|
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
1 """ |
| 29789 | 2 TestCases for DB.associate. |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
3 """ |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
4 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
5 import sys, os, string |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
6 import time |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
7 from pprint import pprint |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
8 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
9 import unittest |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
10 from test_all import db, dbshelve, test_support, verbose, have_threads, \ |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
11 get_new_environment_path |
|
45617
5ccb6eb202ff
Modify import of test_support so that the code can also be used with a
Gregory P. Smith <greg@mad-scientist.com>
parents:
45506
diff
changeset
|
12 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
13 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
14 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
15 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
16 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
17 musicdata = { |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
18 1 : ("Bad English", "The Price Of Love", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
19 2 : ("DNA featuring Suzanne Vega", "Tom's Diner", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
20 3 : ("George Michael", "Praying For Time", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
21 4 : ("Gloria Estefan", "Here We Are", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
22 5 : ("Linda Ronstadt", "Don't Know Much", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
23 6 : ("Michael Bolton", "How Am I Supposed To Live Without You", "Blues"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
24 7 : ("Paul Young", "Oh Girl", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
25 8 : ("Paula Abdul", "Opposites Attract", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
26 9 : ("Richard Marx", "Should've Known Better", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
27 10: ("Rod Stewart", "Forever Young", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
28 11: ("Roxette", "Dangerous", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
29 12: ("Sheena Easton", "The Lover In Me", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
30 13: ("Sinead O'Connor", "Nothing Compares 2 U", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
31 14: ("Stevie B.", "Because I Love You", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
32 15: ("Taylor Dayne", "Love Will Lead You Back", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
33 16: ("The Bangles", "Eternal Flame", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
34 17: ("Wilson Phillips", "Release Me", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
35 18: ("Billy Joel", "Blonde Over Blue", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
36 19: ("Billy Joel", "Famous Last Words", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
37 20: ("Billy Joel", "Lullabye (Goodnight, My Angel)", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
38 21: ("Billy Joel", "The River Of Dreams", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
39 22: ("Billy Joel", "Two Thousand Years", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
40 23: ("Janet Jackson", "Alright", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
41 24: ("Janet Jackson", "Black Cat", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
42 25: ("Janet Jackson", "Come Back To Me", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
43 26: ("Janet Jackson", "Escapade", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
44 27: ("Janet Jackson", "Love Will Never Do (Without You)", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
45 28: ("Janet Jackson", "Miss You Much", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
46 29: ("Janet Jackson", "Rhythm Nation", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
47 30: ("Janet Jackson", "State Of The World", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
48 31: ("Janet Jackson", "The Knowledge", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
49 32: ("Spyro Gyra", "End of Romanticism", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
50 33: ("Spyro Gyra", "Heliopolis", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
51 34: ("Spyro Gyra", "Jubilee", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
52 35: ("Spyro Gyra", "Little Linda", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
53 36: ("Spyro Gyra", "Morning Dance", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
54 37: ("Spyro Gyra", "Song for Lorraine", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
55 38: ("Yes", "Owner Of A Lonely Heart", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
56 39: ("Yes", "Rhythm Of Love", "Rock"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
57 40: ("Cusco", "Dream Catcher", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
58 41: ("Cusco", "Geronimos Laughter", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
59 42: ("Cusco", "Ghost Dance", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
60 43: ("Blue Man Group", "Drumbone", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
61 44: ("Blue Man Group", "Endless Column", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
62 45: ("Blue Man Group", "Klein Mandelbrot", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
63 46: ("Kenny G", "Silhouette", "Jazz"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
64 47: ("Sade", "Smooth Operator", "Jazz"), |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
65 48: ("David Arkenstone", "Papillon (On The Wings Of The Butterfly)", |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
66 "New Age"), |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
67 49: ("David Arkenstone", "Stepping Stars", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
68 50: ("David Arkenstone", "Carnation Lily Lily Rose", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
69 51: ("David Lanz", "Behind The Waterfall", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
70 52: ("David Lanz", "Cristofori's Dream", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
71 53: ("David Lanz", "Heartsounds", "New Age"), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
72 54: ("David Lanz", "Leaves on the Seine", "New Age"), |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
73 99: ("unknown artist", "Unnamed song", "Unknown"), |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
74 } |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
75 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
76 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
77 |
|
35027
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
78 class AssociateErrorTestCase(unittest.TestCase): |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
79 def setUp(self): |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
80 self.filename = self.__class__.__name__ + '.db' |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
81 self.homeDir = get_new_environment_path() |
|
35027
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
82 self.env = db.DBEnv() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
83 self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL) |
|
35027
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
84 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
85 def tearDown(self): |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
86 self.env.close() |
|
36944
7351aab87e6d
Plug the last 657 referenceleaks in test_bsddb3: a circular reference
Thomas Wouters <thomas@python.org>
parents:
35041
diff
changeset
|
87 self.env = None |
|
45506
55eefb43ef6f
Create a db_home directory with a unique name so multiple users can
Neal Norwitz <nnorwitz@gmail.com>
parents:
44987
diff
changeset
|
88 test_support.rmtree(self.homeDir) |
|
35027
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
89 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
90 def test00_associateDBError(self): |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
91 if verbose: |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
92 print '\n', '-=' * 30 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
93 print "Running %s.test00_associateDBError..." % \ |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
94 self.__class__.__name__ |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
95 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
96 dupDB = db.DB(self.env) |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
97 dupDB.set_flags(db.DB_DUP) |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
98 dupDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE) |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
99 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
100 secDB = db.DB(self.env) |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
101 secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE) |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
102 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
103 # dupDB has been configured to allow duplicates, it can't |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
104 # associate with a secondary. Berkeley DB will return an error. |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
105 try: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
106 def f(a,b): return a+b |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
107 dupDB.associate(secDB, f) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
108 except db.DBError: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
109 # good |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
110 secDB.close() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
111 dupDB.close() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
112 else: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
113 secDB.close() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
114 dupDB.close() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
115 self.fail("DBError exception was expected") |
|
35027
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
116 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
117 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
118 |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
119 #---------------------------------------------------------------------- |
|
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
120 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
121 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
122 class AssociateTestCase(unittest.TestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
123 keytype = '' |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
124 envFlags = 0 |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
125 dbFlags = 0 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
126 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
127 def setUp(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
128 self.filename = self.__class__.__name__ + '.db' |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
129 self.homeDir = get_new_environment_path() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
130 self.env = db.DBEnv() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
131 self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
132 db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
133 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
134 def tearDown(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
135 self.closeDB() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
136 self.env.close() |
|
36944
7351aab87e6d
Plug the last 657 referenceleaks in test_bsddb3: a circular reference
Thomas Wouters <thomas@python.org>
parents:
35041
diff
changeset
|
137 self.env = None |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
138 test_support.rmtree(self.homeDir) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
139 |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
140 def addDataToDB(self, d, txn=None): |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
141 for key, value in musicdata.items(): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
142 if type(self.keytype) == type(''): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
143 key = "%02d" % key |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
144 d.put(key, '|'.join(value), txn=txn) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
145 |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
146 def createDB(self, txn=None): |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
147 self.cur = None |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
148 self.secDB = None |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
149 self.primary = db.DB(self.env) |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
150 self.primary.set_get_returns_none(2) |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
151 if db.version() >= (4, 1): |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
152 self.primary.open(self.filename, "primary", self.dbtype, |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
153 db.DB_CREATE | db.DB_THREAD | self.dbFlags, txn=txn) |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
154 else: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
155 self.primary.open(self.filename, "primary", self.dbtype, |
|
35032
d4daababaa45
fix more Errors (not Failures) when run using BerkeleyDB <= 4.0
Gregory P. Smith <greg@mad-scientist.com>
parents:
35031
diff
changeset
|
156 db.DB_CREATE | db.DB_THREAD | self.dbFlags) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
157 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
158 def closeDB(self): |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
159 if self.cur: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
160 self.cur.close() |
|
36944
7351aab87e6d
Plug the last 657 referenceleaks in test_bsddb3: a circular reference
Thomas Wouters <thomas@python.org>
parents:
35041
diff
changeset
|
161 self.cur = None |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
162 if self.secDB: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
163 self.secDB.close() |
|
36944
7351aab87e6d
Plug the last 657 referenceleaks in test_bsddb3: a circular reference
Thomas Wouters <thomas@python.org>
parents:
35041
diff
changeset
|
164 self.secDB = None |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
165 self.primary.close() |
|
36944
7351aab87e6d
Plug the last 657 referenceleaks in test_bsddb3: a circular reference
Thomas Wouters <thomas@python.org>
parents:
35041
diff
changeset
|
166 self.primary = None |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
167 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
168 def getDB(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
169 return self.primary |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
170 |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
171 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
172 def test01_associateWithDB(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
173 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
174 print '\n', '-=' * 30 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
175 print "Running %s.test01_associateWithDB..." % \ |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
176 self.__class__.__name__ |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
177 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
178 self.createDB() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
179 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
180 self.secDB = db.DB(self.env) |
|
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
181 self.secDB.set_flags(db.DB_DUP) |
|
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
182 self.secDB.set_get_returns_none(2) |
|
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
183 self.secDB.open(self.filename, "secondary", db.DB_BTREE, |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
184 db.DB_CREATE | db.DB_THREAD | self.dbFlags) |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
185 self.getDB().associate(self.secDB, self.getGenre) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
186 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
187 self.addDataToDB(self.getDB()) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
188 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
189 self.finish_test(self.secDB) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
190 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
191 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
192 def test02_associateAfterDB(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
193 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
194 print '\n', '-=' * 30 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
195 print "Running %s.test02_associateAfterDB..." % \ |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
196 self.__class__.__name__ |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
197 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
198 self.createDB() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
199 self.addDataToDB(self.getDB()) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
200 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
201 self.secDB = db.DB(self.env) |
|
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
202 self.secDB.set_flags(db.DB_DUP) |
|
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
203 self.secDB.open(self.filename, "secondary", db.DB_BTREE, |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
204 db.DB_CREATE | db.DB_THREAD | self.dbFlags) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
205 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
206 # adding the DB_CREATE flag will cause it to index existing records |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
207 self.getDB().associate(self.secDB, self.getGenre, db.DB_CREATE) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
208 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
209 self.finish_test(self.secDB) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
210 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
211 |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
212 def finish_test(self, secDB, txn=None): |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
213 # 'Blues' should not be in the secondary database |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
214 vals = secDB.pget('Blues', txn=txn) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
215 self.assertEqual(vals, None, vals) |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
216 |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
217 vals = secDB.pget('Unknown', txn=txn) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
218 self.assert_(vals[0] == 99 or vals[0] == '99', vals) |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
219 vals[1].index('Unknown') |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
220 vals[1].index('Unnamed') |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
221 vals[1].index('unknown') |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
222 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
223 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
224 print "Primary key traversal:" |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
225 self.cur = self.getDB().cursor(txn) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
226 count = 0 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
227 rec = self.cur.first() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
228 while rec is not None: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
229 if type(self.keytype) == type(''): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
230 self.assert_(int(rec[0])) # for primary db, key is a number |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
231 else: |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
232 self.assert_(rec[0] and type(rec[0]) == type(0)) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
233 count = count + 1 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
234 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
235 print rec |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
236 rec = getattr(self.cur, "next")() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
237 self.assertEqual(count, len(musicdata)) # all items accounted for |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
238 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
239 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
240 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
241 print "Secondary key traversal:" |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
242 self.cur = secDB.cursor(txn) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
243 count = 0 |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
244 |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
245 # test cursor pget |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
246 vals = self.cur.pget('Unknown', flags=db.DB_LAST) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
247 self.assert_(vals[1] == 99 or vals[1] == '99', vals) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
248 self.assertEqual(vals[0], 'Unknown') |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
249 vals[2].index('Unknown') |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
250 vals[2].index('Unnamed') |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
251 vals[2].index('unknown') |
|
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
252 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
253 vals = self.cur.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
254 self.assertEqual(vals, None, vals) |
|
32431
c7d2b24eeff9
Adds support for DB.pget and DBCursor.pget methods.
Gregory P. Smith <greg@mad-scientist.com>
parents:
31515
diff
changeset
|
255 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
256 rec = self.cur.first() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
257 self.assertEqual(rec[0], "Jazz") |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
258 while rec is not None: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
259 count = count + 1 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
260 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
261 print rec |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
262 rec = getattr(self.cur, "next")() |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
263 # all items accounted for EXCEPT for 1 with "Blues" genre |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
264 self.assertEqual(count, len(musicdata)-1) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
265 |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
266 self.cur = None |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
267 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
268 def getGenre(self, priKey, priData): |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
269 self.assertEqual(type(priData), type("")) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
270 genre = priData.split('|')[2] |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
271 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
272 if verbose: |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
30475
diff
changeset
|
273 print 'getGenre key: %r data: %r' % (priKey, priData) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
274 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
275 if genre == 'Blues': |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
276 return db.DB_DONOTINDEX |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
277 else: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
278 return genre |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
279 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
280 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
281 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
282 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
283 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
284 class AssociateHashTestCase(AssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
285 dbtype = db.DB_HASH |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
286 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
287 class AssociateBTreeTestCase(AssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
288 dbtype = db.DB_BTREE |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
289 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
290 class AssociateRecnoTestCase(AssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
291 dbtype = db.DB_RECNO |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
292 keytype = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
293 |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
294 #---------------------------------------------------------------------- |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
295 |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
296 class AssociateBTreeTxnTestCase(AssociateBTreeTestCase): |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
297 envFlags = db.DB_INIT_TXN |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
298 dbFlags = 0 |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
299 |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
300 def txn_finish_test(self, sDB, txn): |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
301 try: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
302 self.finish_test(sDB, txn=txn) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
303 finally: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
304 if self.cur: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
305 self.cur.close() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
306 self.cur = None |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
307 if txn: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
308 txn.commit() |
|
35031
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
309 |
|
b73f130c7b84
fix Errors (not Failures) in test cases when running with BerkeleyDB<4.2
Gregory P. Smith <greg@mad-scientist.com>
parents:
35027
diff
changeset
|
310 def test13_associate_in_transaction(self): |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
311 if verbose: |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
312 print '\n', '-=' * 30 |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
313 print "Running %s.test13_associateAutoCommit..." % \ |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
314 self.__class__.__name__ |
|
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
315 |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
316 txn = self.env.txn_begin() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
317 try: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
318 self.createDB(txn=txn) |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
319 |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
320 self.secDB = db.DB(self.env) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
321 self.secDB.set_flags(db.DB_DUP) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
322 self.secDB.set_get_returns_none(2) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
323 self.secDB.open(self.filename, "secondary", db.DB_BTREE, |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
324 db.DB_CREATE | db.DB_THREAD, txn=txn) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
325 if db.version() >= (4,1): |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
326 self.getDB().associate(self.secDB, self.getGenre, txn=txn) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
327 else: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
328 self.getDB().associate(self.secDB, self.getGenre) |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
329 |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
330 self.addDataToDB(self.getDB(), txn=txn) |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
331 except: |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
332 txn.abort() |
|
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
333 raise |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
334 |
|
35041
1490f811f93a
Tools/scripts/reindent.py _is_ your friend
Anthony Baxter <anthonybaxter@gmail.com>
parents:
35032
diff
changeset
|
335 self.txn_finish_test(self.secDB, txn=txn) |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
336 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
337 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
338 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
339 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
340 class ShelveAssociateTestCase(AssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
341 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
342 def createDB(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
343 self.primary = dbshelve.open(self.filename, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
344 dbname="primary", |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
345 dbenv=self.env, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
346 filetype=self.dbtype) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
347 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
348 def addDataToDB(self, d): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
349 for key, value in musicdata.items(): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
350 if type(self.keytype) == type(''): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
351 key = "%02d" % key |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
352 d.put(key, value) # save the value as is this time |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
353 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
354 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
355 def getGenre(self, priKey, priData): |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
356 self.assertEqual(type(priData), type(())) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
357 if verbose: |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
30475
diff
changeset
|
358 print 'getGenre key: %r data: %r' % (priKey, priData) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
359 genre = priData[2] |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
360 if genre == 'Blues': |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
361 return db.DB_DONOTINDEX |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
362 else: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
363 return genre |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
364 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
365 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
366 class ShelveAssociateHashTestCase(ShelveAssociateTestCase): |
|
26387
fcf9734e1021
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
26288
diff
changeset
|
367 dbtype = db.DB_HASH |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
368 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
369 class ShelveAssociateBTreeTestCase(ShelveAssociateTestCase): |
|
26387
fcf9734e1021
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
26288
diff
changeset
|
370 dbtype = db.DB_BTREE |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
371 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
372 class ShelveAssociateRecnoTestCase(ShelveAssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
373 dbtype = db.DB_RECNO |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
374 keytype = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
375 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
376 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
377 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
378 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
379 class ThreadedAssociateTestCase(AssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
380 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
381 def addDataToDB(self, d): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
382 t1 = Thread(target = self.writer1, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
383 args = (d, )) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
384 t2 = Thread(target = self.writer2, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
385 args = (d, )) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
386 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
387 t1.setDaemon(True) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45617
diff
changeset
|
388 t2.setDaemon(True) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
389 t1.start() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
390 t2.start() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
391 t1.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
392 t2.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
393 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
394 def writer1(self, d): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
395 for key, value in musicdata.items(): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
396 if type(self.keytype) == type(''): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
397 key = "%02d" % key |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
398 d.put(key, '|'.join(value)) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
399 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
400 def writer2(self, d): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
401 for x in range(100, 600): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
402 key = 'z%2d' % x |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
403 value = [key] * 4 |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
404 d.put(key, '|'.join(value)) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
405 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
406 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
407 class ThreadedAssociateHashTestCase(ShelveAssociateTestCase): |
|
26387
fcf9734e1021
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
26288
diff
changeset
|
408 dbtype = db.DB_HASH |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
409 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
410 class ThreadedAssociateBTreeTestCase(ShelveAssociateTestCase): |
|
26387
fcf9734e1021
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
26288
diff
changeset
|
411 dbtype = db.DB_BTREE |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
412 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
413 class ThreadedAssociateRecnoTestCase(ShelveAssociateTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
414 dbtype = db.DB_RECNO |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
415 keytype = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
416 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
417 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
418 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
419 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
420 def test_suite(): |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
421 suite = unittest.TestSuite() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
422 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
423 suite.addTest(unittest.makeSuite(AssociateErrorTestCase)) |
|
35027
329b28a85947
test case for pybsddb SF bug id 1215432
Gregory P. Smith <greg@mad-scientist.com>
parents:
35025
diff
changeset
|
424 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
425 suite.addTest(unittest.makeSuite(AssociateHashTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
426 suite.addTest(unittest.makeSuite(AssociateBTreeTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
427 suite.addTest(unittest.makeSuite(AssociateRecnoTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
428 |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
429 if db.version() >= (4, 1): |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
430 suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
431 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
432 suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
433 suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
434 suite.addTest(unittest.makeSuite(ShelveAssociateRecnoTestCase)) |
|
35025
5a1a31d9e37e
test DB.associate using transactions. somewhat related to SF pybsddb
Gregory P. Smith <greg@mad-scientist.com>
parents:
32431
diff
changeset
|
435 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
436 if have_threads: |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
437 suite.addTest(unittest.makeSuite(ThreadedAssociateHashTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
438 suite.addTest(unittest.makeSuite(ThreadedAssociateBTreeTestCase)) |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
439 suite.addTest(unittest.makeSuite(ThreadedAssociateRecnoTestCase)) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
440 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
441 return suite |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
442 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
443 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
444 if __name__ == '__main__': |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
445 unittest.main(defaultTest='test_suite') |
