<s> """<STR_LIT>""" <EOL> import sys , os , string <EOL> import tempfile <EOL> from pprint import pprint <EOL> import unittest <EOL> try : <EOL> from bsddb3 import db <EOL> except ImportError : <EOL> from bsddb import db <EOL> from test_all import verbose <EOL> class SimpleQueueTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . filename = tempfile . mktemp ( ) <EOL> def tearDown ( self ) : <EOL> try : <EOL> os . remove ( self . filename ) <EOL> except os . error : <EOL> pass <EOL> def test01_basic ( self ) : <EOL> if verbose : <EOL> print '<STR_LIT:\n>' , '<STR_LIT>' * <NUM_LIT:30> <EOL> print "<STR_LIT>" % self . __class__ . __name__ <EOL> d = db . DB ( ) <EOL> d . set_re_len ( <NUM_LIT> ) <EOL> d . open ( self . filename , db . DB_QUEUE , db . DB_CREATE ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> for x in string . letters : <EOL> d . append ( x * <NUM_LIT> ) <EOL> assert len ( d ) == <NUM_LIT> <EOL> d . put ( <NUM_LIT:100> , "<STR_LIT>" ) <EOL> d . put ( <NUM_LIT> , "<STR_LIT>" ) <EOL> d . put ( <NUM_LIT> , "<STR_LIT>" ) <EOL> d . put ( <NUM_LIT:1> , "<STR_LIT>" ) <EOL> assert len ( d ) == <NUM_LIT> <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> d . close ( ) <EOL> del d <EOL> d = db . DB ( ) <EOL> d . open ( self . filename ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> d . append ( "<STR_LIT>" ) <EOL> c = d . cursor ( ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> rec = c . consume ( ) <EOL> while rec : <EOL> if verbose : <EOL> print rec <EOL> rec = c . consume ( ) <EOL> c . close ( ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> assert len ( d ) == <NUM_LIT:0> , "<STR_LIT>" "<STR_LIT>" <EOL> d . close ( ) <EOL> def test02_basicPost32 ( self ) : <EOL> if verbose : <EOL> print '<STR_LIT:\n>' , '<STR_LIT>' * <NUM_LIT:30> <EOL> print "<STR_LIT>" % self . __class__ . __name__ <EOL> if db . version ( ) < ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:0> ) : <EOL> if verbose : <EOL> print "<STR_LIT>" <EOL> return <EOL> d = db . DB ( ) <EOL> d . set_re_len ( <NUM_LIT> ) <EOL> d . open ( self . filename , db . DB_QUEUE , db . DB_CREATE ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> for x in string . letters : <EOL> d . append ( x * <NUM_LIT> ) <EOL> assert len ( d ) == <NUM_LIT> <EOL> d . put ( <NUM_LIT:100> , "<STR_LIT>" ) <EOL> d . put ( <NUM_LIT> , "<STR_LIT>" ) <EOL> d . put ( <NUM_LIT> , "<STR_LIT>" ) <EOL> d . put ( <NUM_LIT:1> , "<STR_LIT>" ) <EOL> assert len ( d ) == <NUM_LIT> <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> d . close ( ) <EOL> del d <EOL> d = db . DB ( ) <EOL> d . open ( self . filename ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> d . append ( "<STR_LIT>" ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> rec = d . consume ( ) <EOL> while rec : <EOL> if verbose : <EOL> print rec <EOL> rec = d . consume ( ) <EOL> if verbose : <EOL> print "<STR_LIT>" + '<STR_LIT:->' * <NUM_LIT:30> <EOL> pprint ( d . stat ( ) ) <EOL> d . close ( ) <EOL> def test_suite ( ) : <EOL> return unittest . makeSuite ( SimpleQueueTestCase ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
