diff options
author | Tim Peters <tim.peters@gmail.com> | 2006-06-05 20:49:27 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2006-06-05 20:49:27 (GMT) |
commit | c169e9f19cd53c2501a8dd9c906c980ea4105d16 (patch) | |
tree | 82f6837667032581ac11b80016a0740571580cc4 /Lib/bsddb/test | |
parent | 852eae1bc11cf53a56aaeb0bf2a8d5308df3eb4d (diff) | |
download | cpython-c169e9f19cd53c2501a8dd9c906c980ea4105d16.zip cpython-c169e9f19cd53c2501a8dd9c906c980ea4105d16.tar.gz cpython-c169e9f19cd53c2501a8dd9c906c980ea4105d16.tar.bz2 |
Add missing svn:eol-style property to text files.
Diffstat (limited to 'Lib/bsddb/test')
-rw-r--r-- | Lib/bsddb/test/test_cursor_pget_bug.py | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/Lib/bsddb/test/test_cursor_pget_bug.py b/Lib/bsddb/test/test_cursor_pget_bug.py index 8ac5f6c..de47e6d 100644 --- a/Lib/bsddb/test/test_cursor_pget_bug.py +++ b/Lib/bsddb/test/test_cursor_pget_bug.py @@ -1,65 +1,65 @@ -import unittest
-import sys, os, glob
-
-try:
- # For Pythons w/distutils pybsddb
- from bsddb3 import db
-except ImportError:
- # For Python 2.3
- from bsddb import db
-
-
-#----------------------------------------------------------------------
-
-class pget_bugTestCase(unittest.TestCase):
- """Verify that cursor.pget works properly"""
- db_name = 'test-cursor_pget.db'
-
- def setUp(self):
- self.homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
- try:
- os.mkdir(self.homeDir)
- except os.error:
- pass
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- self.primary_db = db.DB(self.env)
- self.primary_db.open(self.db_name, 'primary', db.DB_BTREE, db.DB_CREATE)
- self.secondary_db = db.DB(self.env)
- self.secondary_db.set_flags(db.DB_DUP)
- self.secondary_db.open(self.db_name, 'secondary', db.DB_BTREE, db.DB_CREATE)
- self.primary_db.associate(self.secondary_db, lambda key, data: data)
- self.primary_db.put('salad', 'eggs')
- self.primary_db.put('spam', 'ham')
- self.primary_db.put('omelet', 'eggs')
-
-
- def tearDown(self):
- self.secondary_db.close()
- self.primary_db.close()
- self.env.close()
- del self.secondary_db
- del self.primary_db
- del self.env
- for file in glob.glob(os.path.join(self.homeDir, '*')):
- os.remove(file)
- os.removedirs(self.homeDir)
-
- def test_pget(self):
- cursor = self.secondary_db.cursor()
-
- self.assertEquals(('eggs', 'salad', 'eggs'), cursor.pget(key='eggs', flags=db.DB_SET))
- self.assertEquals(('eggs', 'omelet', 'eggs'), cursor.pget(db.DB_NEXT_DUP))
- self.assertEquals(None, cursor.pget(db.DB_NEXT_DUP))
-
- self.assertEquals(('ham', 'spam', 'ham'), cursor.pget('ham', 'spam', flags=db.DB_SET))
- self.assertEquals(None, cursor.pget(db.DB_NEXT_DUP))
-
- cursor.close()
-
-
-def test_suite():
- return unittest.makeSuite(pget_bugTestCase)
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+import unittest +import sys, os, glob + +try: + # For Pythons w/distutils pybsddb + from bsddb3 import db +except ImportError: + # For Python 2.3 + from bsddb import db + + +#---------------------------------------------------------------------- + +class pget_bugTestCase(unittest.TestCase): + """Verify that cursor.pget works properly""" + db_name = 'test-cursor_pget.db' + + def setUp(self): + self.homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') + try: + os.mkdir(self.homeDir) + except os.error: + pass + self.env = db.DBEnv() + self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL) + self.primary_db = db.DB(self.env) + self.primary_db.open(self.db_name, 'primary', db.DB_BTREE, db.DB_CREATE) + self.secondary_db = db.DB(self.env) + self.secondary_db.set_flags(db.DB_DUP) + self.secondary_db.open(self.db_name, 'secondary', db.DB_BTREE, db.DB_CREATE) + self.primary_db.associate(self.secondary_db, lambda key, data: data) + self.primary_db.put('salad', 'eggs') + self.primary_db.put('spam', 'ham') + self.primary_db.put('omelet', 'eggs') + + + def tearDown(self): + self.secondary_db.close() + self.primary_db.close() + self.env.close() + del self.secondary_db + del self.primary_db + del self.env + for file in glob.glob(os.path.join(self.homeDir, '*')): + os.remove(file) + os.removedirs(self.homeDir) + + def test_pget(self): + cursor = self.secondary_db.cursor() + + self.assertEquals(('eggs', 'salad', 'eggs'), cursor.pget(key='eggs', flags=db.DB_SET)) + self.assertEquals(('eggs', 'omelet', 'eggs'), cursor.pget(db.DB_NEXT_DUP)) + self.assertEquals(None, cursor.pget(db.DB_NEXT_DUP)) + + self.assertEquals(('ham', 'spam', 'ham'), cursor.pget('ham', 'spam', flags=db.DB_SET)) + self.assertEquals(None, cursor.pget(db.DB_NEXT_DUP)) + + cursor.close() + + +def test_suite(): + return unittest.makeSuite(pget_bugTestCase) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') |