当前位置: 首页>>代码示例>>Python>>正文


Python db.version函数代码示例

本文整理汇总了Python中test_all.db.version函数的典型用法代码示例。如果您正苦于以下问题:Python version函数的具体用法?Python version怎么用?Python version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_suite

def test_suite():
    suite = unittest.TestSuite()
    if db.version() >= (4,5) :
        suite.addTest(unittest.makeSuite(DBTxn_distributed))
        suite.addTest(unittest.makeSuite(DBTxn_distributedSYNC))
    if db.version() >= (4,6) :
        suite.addTest(unittest.makeSuite(DBTxn_distributed_must_open_db))
        suite.addTest(unittest.makeSuite(DBTxn_distributedSYNC_must_open_db))
    return suite
开发者ID:2uller,项目名称:LotF,代码行数:9,代码来源:test_distributed_transactions.py

示例2: test13_associate_in_transaction

    def test13_associate_in_transaction(self):
        if verbose:
            print '\n', '-=' * 30
            print "Running %s.test13_associateAutoCommit..." % \
                  self.__class__.__name__

        txn = self.env.txn_begin()
        try:
            self.createDB(txn=txn)

            self.secDB = db.DB(self.env)
            self.secDB.set_flags(db.DB_DUP)
            self.secDB.set_get_returns_none(2)
            self.secDB.open(self.filename, "secondary", db.DB_BTREE,
                       db.DB_CREATE | db.DB_THREAD, txn=txn)
            if db.version() >= (4,1):
                self.getDB().associate(self.secDB, self.getGenre, txn=txn)
            else:
                self.getDB().associate(self.secDB, self.getGenre)

            self.addDataToDB(self.getDB(), txn=txn)
        except:
            txn.abort()
            raise

        self.txn_finish_test(self.secDB, txn=txn)
开发者ID:1310701102,项目名称:sl4a,代码行数:26,代码来源:test_associate.py

示例3: test07_DB_set_flags_persists

 def test07_DB_set_flags_persists(self):
     if db.version() < (4,2):
         # The get_flags API required for this to work is only available
         # in Berkeley DB >= 4.2
         return
     try:
         db1 = db.DB()
         db1.set_flags(db.DB_DUPSORT)
         db1.open(self.filename, db.DB_HASH, db.DB_CREATE)
         db1['a'] = 'eh'
         db1['a'] = 'A'
         self.assertEqual([('a', 'A')], db1.items())
         db1.put('a', 'Aa')
         self.assertEqual([('a', 'A'), ('a', 'Aa')], db1.items())
         db1.close()
         db1 = db.DB()
         # no set_flags call, we're testing that it reads and obeys
         # the flags on open.
         db1.open(self.filename, db.DB_HASH)
         self.assertEqual([('a', 'A'), ('a', 'Aa')], db1.items())
         # if it read the flags right this will replace all values
         # for key 'a' instead of adding a new one.  (as a dict should)
         db1['a'] = 'new A'
         self.assertEqual([('a', 'new A')], db1.items())
     finally:
         db1.close()
         test_support.unlink(self.filename)
开发者ID:CaoYouXin,项目名称:myfirstapicloudapp,代码行数:27,代码来源:test_misc.py

示例4: test06_Transactions

    def test06_Transactions(self):
        d = self.d
        if verbose:
            print '\n', '-=' * 30
            print "Running %s.test06_Transactions..." % self.__class__.__name__

        self.assertEqual(d.get('new rec', txn=self.txn), None)
        d.put('new rec', 'this is a new record', self.txn)
        self.assertEqual(
            d.get('new rec', txn=self.txn), 'this is a new record')
        self.txn.abort()
        self.assertEqual(d.get('new rec'), None)

        self.txn = self.env.txn_begin()

        self.assertEqual(d.get('new rec', txn=self.txn), None)
        d.put('new rec', 'this is a new record', self.txn)
        self.assertEqual(
            d.get('new rec', txn=self.txn), 'this is a new record')
        self.txn.commit()
        self.assertEqual(d.get('new rec'), 'this is a new record')

        self.txn = self.env.txn_begin()
        c = d.cursor(self.txn)
        rec = c.first()
        count = 0
        while rec is not None:
            count = count + 1
            if verbose and count % 100 == 0:
                print rec
            rec = c.next()
        self.assertEqual(count, self._numKeys + 1)

        c.close()  # Cursors *MUST* be closed before commit!
        self.txn.commit()

        # flush pending updates
        try:
            self.env.txn_checkpoint(0, 0, 0)
        except db.DBIncompleteError:
            pass

        statDict = self.env.log_stat(0)
        self.assertTrue('magic' in statDict)
        self.assertTrue('version' in statDict)
        self.assertTrue('cur_file' in statDict)
        self.assertTrue('region_nowait' in statDict)

        # must have at least one log file present:
        logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
        self.assertNotEqual(logs, None)
        for log in logs:
            if verbose:
                print 'log file: ' + log
        if db.version() >= (4, 2):
            logs = self.env.log_archive(db.DB_ARCH_REMOVE)
            self.assertTrue(not logs)

        self.txn = self.env.txn_begin()
开发者ID:Rogerlin2013,项目名称:CrossApp,代码行数:59,代码来源:test_basics.py

示例5: test00_version

 def test00_version(self):
     info = db.version()
     if verbose:
         print "\n", "-=" * 20
         print "bsddb.db.version(): %s" % (info,)
         print db.DB_VERSION_STRING
         print "-=" * 20
     self.assertEqual(info, (db.DB_VERSION_MAJOR, db.DB_VERSION_MINOR, db.DB_VERSION_PATCH))
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:8,代码来源:test_basics.py

示例6: test_lk_detect

        def test_lk_detect(self) :
            flags= [db.DB_LOCK_DEFAULT, db.DB_LOCK_EXPIRE, db.DB_LOCK_MAXLOCKS,
                    db.DB_LOCK_MINLOCKS, db.DB_LOCK_MINWRITE,
                    db.DB_LOCK_OLDEST, db.DB_LOCK_RANDOM, db.DB_LOCK_YOUNGEST]

            if db.version() >= (4, 3) :
                flags.append(db.DB_LOCK_MAXWRITE)

            for i in flags :
                self.env.set_lk_detect(i)
                self.assertEqual(i, self.env.get_lk_detect())
开发者ID:1018365842,项目名称:FreeIMU,代码行数:11,代码来源:test_dbenv.py

示例7: createDB

 def createDB(self, txn=None):
     self.cur = None
     self.secDB = None
     self.primary = db.DB(self.env)
     self.primary.set_get_returns_none(2)
     if db.version() >= (4, 1):
         self.primary.open(self.filename, "primary", self.dbtype,
                       db.DB_CREATE | db.DB_THREAD | self.dbFlags, txn=txn)
     else:
         self.primary.open(self.filename, "primary", self.dbtype,
                       db.DB_CREATE | db.DB_THREAD | self.dbFlags)
开发者ID:1310701102,项目名称:sl4a,代码行数:11,代码来源:test_associate.py

示例8: test04_lock_timeout2

    def test04_lock_timeout2(self):
        self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
        self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
        self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
        self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)

        def deadlock_detection() :
            while not deadlock_detection.end :
                deadlock_detection.count = \
                    self.env.lock_detect(db.DB_LOCK_EXPIRE)
                if deadlock_detection.count :
                    while not deadlock_detection.end :
                        pass
                    break
                time.sleep(0.01)

        deadlock_detection.end=False
        deadlock_detection.count=0
        t=Thread(target=deadlock_detection)
        import sys
        if sys.version_info[0] < 3 :
            t.setDaemon(True)
        else :
            t.daemon = True
        t.start()
        self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
        anID = self.env.lock_id()
        anID2 = self.env.lock_id()
        self.assertNotEqual(anID, anID2)
        lock = self.env.lock_get(anID, "shared lock", db.DB_LOCK_WRITE)
        start_time=time.time()
        self.assertRaises(db.DBLockNotGrantedError,
                self.env.lock_get,anID2, "shared lock", db.DB_LOCK_READ)
        end_time=time.time()
        deadlock_detection.end=True
        # Floating point rounding
        if sys.platform == 'win32':
            # bpo-30850: On Windows, tolerate 50 ms whereas 100 ms is expected.
            # The lock sometimes times out after only 58 ms. Windows clocks
            # have a bad resolution and bad accuracy.
            min_dt = 0.050
        else:
            min_dt = 0.0999
        self.assertGreaterEqual(end_time-start_time, min_dt)
        self.env.lock_put(lock)
        t.join()

        self.env.lock_id_free(anID)
        self.env.lock_id_free(anID2)

        if db.version() >= (4,6):
            self.assertGreater(deadlock_detection.count, 0)
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:52,代码来源:test_lock.py

示例9: setUp

    def setUp(self):
        if self.useEnv:
            self.homeDir=get_new_environment_path()
            try:
                self.env = db.DBEnv()
                self.env.set_lg_max(1024*1024)
                self.env.set_tx_max(30)
                self._t = int(time.time())
                self.env.set_tx_timestamp(self._t)
                self.env.set_flags(self.envsetflags, 1)
                self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
                self.filename = "test"
            # Yes, a bare except is intended, since we're re-raising the exc.
            except:
                test_support.rmtree(self.homeDir)
                raise
        else:
            self.env = None
            self.filename = get_new_database_path()

        # create and open the DB
        self.d = db.DB(self.env)
        if not self.useEnv :
            if db.version() >= (4, 2) :
                self.d.set_cachesize(*self.cachesize)
                cachesize = self.d.get_cachesize()
                self.assertEqual(cachesize[0], self.cachesize[0])
                self.assertEqual(cachesize[2], self.cachesize[2])
                # Berkeley DB expands the cache 25% accounting overhead,
                # if the cache is small.
                self.assertEqual(125, int(100.0*cachesize[1]/self.cachesize[1]))
        self.d.set_flags(self.dbsetflags)
        if self.dbname:
            self.d.open(self.filename, self.dbname, self.dbtype,
                        self.dbopenflags|db.DB_CREATE, self.dbmode)
        else:
            self.d.open(self.filename,   # try out keyword args
                        mode = self.dbmode,
                        dbtype = self.dbtype,
                        flags = self.dbopenflags|db.DB_CREATE)

        if not self.useEnv:
            self.assertRaises(db.DBInvalidArgError,
                    self.d.set_cachesize, *self.cachesize)

        self.populateDB()
开发者ID:kanbang,项目名称:Colt,代码行数:46,代码来源:test_basics.py

示例10: test_suite

def test_suite():
    suite = unittest.TestSuite()
    if db.version() >= (4, 6):
        dbenv = db.DBEnv()
        try:
            dbenv.repmgr_get_ack_policy()
            ReplicationManager_available = True
        except:
            ReplicationManager_available = False

        dbenv.close()
        del dbenv
        if ReplicationManager_available:
            suite.addTest(unittest.makeSuite(DBReplicationManager))
        if have_threads:
            suite.addTest(unittest.makeSuite(DBBaseReplication))
    return suite
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:17,代码来源:test_replication.py

示例11: test04_lock_timeout2

    def test04_lock_timeout2(self):
        self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
        self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
        self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
        self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)

        def deadlock_detection() :
            while not deadlock_detection.end :
                deadlock_detection.count = \
                    self.env.lock_detect(db.DB_LOCK_EXPIRE)
                if deadlock_detection.count :
                    while not deadlock_detection.end :
                        pass
                    break
                time.sleep(0.01)

        deadlock_detection.end=False
        deadlock_detection.count=0
        t=Thread(target=deadlock_detection)
        import sys
        if sys.version_info[0] < 3 :
            t.setDaemon(True)
        else :
            t.daemon = True
        t.start()
        self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
        anID = self.env.lock_id()
        anID2 = self.env.lock_id()
        self.assertNotEqual(anID, anID2)
        lock = self.env.lock_get(anID, "shared lock", db.DB_LOCK_WRITE)
        start_time=time.time()
        self.assertRaises(db.DBLockNotGrantedError,
                self.env.lock_get,anID2, "shared lock", db.DB_LOCK_READ)
        end_time=time.time()
        deadlock_detection.end=True
        # Floating point rounding
        self.assertTrue((end_time-start_time) >= 0.0999)
        self.env.lock_put(lock)
        t.join()

        self.env.lock_id_free(anID)
        self.env.lock_id_free(anID2)

        if db.version() >= (4,6):
            self.assertTrue(deadlock_detection.count>0)
开发者ID:1018365842,项目名称:FreeIMU,代码行数:45,代码来源:test_lock.py

示例12: test_suite

def test_suite():
    suite = unittest.TestSuite()

    suite.addTest(unittest.makeSuite(AssociateErrorTestCase))

    suite.addTest(unittest.makeSuite(AssociateHashTestCase))
    suite.addTest(unittest.makeSuite(AssociateBTreeTestCase))
    suite.addTest(unittest.makeSuite(AssociateRecnoTestCase))

    if db.version() >= (4, 1):
        suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))

    suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase))
    suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase))
    suite.addTest(unittest.makeSuite(ShelveAssociateRecnoTestCase))

    if have_threads:
        suite.addTest(unittest.makeSuite(ThreadedAssociateHashTestCase))
        suite.addTest(unittest.makeSuite(ThreadedAssociateBTreeTestCase))
        suite.addTest(unittest.makeSuite(ThreadedAssociateRecnoTestCase))

    return suite
开发者ID:1310701102,项目名称:sl4a,代码行数:22,代码来源:test_associate.py

示例13: test06_close_txn_before_dup_cursor

 def test06_close_txn_before_dup_cursor(self) :
     dbenv = db.DBEnv()
     dbenv.open(self.homeDir,db.DB_INIT_TXN | db.DB_INIT_MPOOL |
             db.DB_INIT_LOG | db.DB_CREATE)
     d = db.DB(dbenv)
     txn = dbenv.txn_begin()
     if db.version() < (4,1) :
         d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE)
     else :
         d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE,
                 txn=txn)
     d.put("XXX", "yyy", txn=txn)
     txn.commit()
     txn = dbenv.txn_begin()
     c1 = d.cursor(txn)
     c2 = c1.dup()
     self.assertEquals(("XXX", "yyy"), c1.first())
     import warnings
     # Not interested in warnings about implicit close.
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         txn.commit()
     self.assertRaises(db.DBCursorClosedError, c2.first)
开发者ID:1310701102,项目名称:sl4a,代码行数:23,代码来源:test_early_close.py

示例14: _create_env

 def _create_env(self, must_open_db) :
     self.dbenv = db.DBEnv()
     self.dbenv.set_tx_max(self.num_txns)
     self.dbenv.set_lk_max_lockers(self.num_txns*2)
     self.dbenv.set_lk_max_locks(self.num_txns*2)
     self.dbenv.set_lk_max_objects(self.num_txns*2)
     if self.nosync :
         self.dbenv.set_flags(db.DB_TXN_NOSYNC,True)
     self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_THREAD |
             db.DB_RECOVER |
             db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL |
             db.DB_INIT_LOCK, 0666)
     self.db = db.DB(self.dbenv)
     self.db.set_re_len(db.DB_GID_SIZE)
     if must_open_db :
         if db.version() >= (4,2) :
             txn=self.dbenv.txn_begin()
             self.db.open(self.filename,
                     db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666,
                     txn=txn)
             txn.commit()
         else :
             self.db.open(self.filename,
                     db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666)
开发者ID:89sos98,项目名称:main,代码行数:24,代码来源:test_distributed_transactions.py

示例15: test01_basic_replication

    def test01_basic_replication(self) :
        self.basic_rep_threading()

        # The timeout is necessary in BDB 4.5, since DB_EVENT_REP_STARTUPDONE
        # is not generated if the master has no new transactions.
        # This is solved in BDB 4.6 (#15542).
        import time
        timeout = time.time()+10
        while (time.time()<timeout) and not (self.confirmed_master and
                self.client_startupdone) :
            time.sleep(0.02)
        self.assertTrue(time.time()<timeout)

        self.dbMaster=db.DB(self.dbenvMaster)
        txn=self.dbenvMaster.txn_begin()
        self.dbMaster.open("test", db.DB_HASH, db.DB_CREATE, 0666, txn=txn)
        txn.commit()

        import time,os.path
        timeout=time.time()+10
        while (time.time()<timeout) and \
          not (os.path.exists(os.path.join(self.homeDirClient,"test"))) :
            time.sleep(0.01)

        self.dbClient=db.DB(self.dbenvClient)
        while True :
            txn=self.dbenvClient.txn_begin()
            try :
                self.dbClient.open("test", db.DB_HASH, flags=db.DB_RDONLY,
                        mode=0666, txn=txn)
            except db.DBRepHandleDeadError :
                txn.abort()
                self.dbClient.close()
                self.dbClient=db.DB(self.dbenvClient)
                continue

            txn.commit()
            break

        if db.version() >= (4,1) :
            d = self.dbenvMaster.rep_stat(flags=db.DB_STAT_CLEAR);
            self.assertTrue("master_changes" in d)

        txn=self.dbenvMaster.txn_begin()
        self.dbMaster.put("ABC", "123", txn=txn)
        txn.commit()
        import time
        timeout=time.time()+10
        v=None
        while (time.time()<timeout) and (v==None) :
            txn=self.dbenvClient.txn_begin()
            v=self.dbClient.get("ABC", txn=txn)
            txn.commit()
            if v==None :
                time.sleep(0.02)
        self.assertTrue(time.time()<timeout)
        self.assertEquals("123", v)

        txn=self.dbenvMaster.txn_begin()
        self.dbMaster.delete("ABC", txn=txn)
        txn.commit()
        timeout=time.time()+10
        while (time.time()<timeout) and (v!=None) :
            txn=self.dbenvClient.txn_begin()
            v=self.dbClient.get("ABC", txn=txn)
            txn.commit()
            if v==None :
                time.sleep(0.02)
        self.assertTrue(time.time()<timeout)
        self.assertEquals(None, v)
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:70,代码来源:test_replication.py


注:本文中的test_all.db.version函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。