summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorAnthony Baxter <anthonybaxter@gmail.com>2005-06-08 04:35:50 (GMT)
committerAnthony Baxter <anthonybaxter@gmail.com>2005-06-08 04:35:50 (GMT)
commit95a2a4ea701e0bc7b2afb778b1f0c1e4b4d89624 (patch)
treefa0ed5e1abd15837fda142a40992066e2c453d05 /Lib/bsddb
parent684364c646543c4d017207219aba73f683683c5d (diff)
downloadcpython-95a2a4ea701e0bc7b2afb778b1f0c1e4b4d89624.zip
cpython-95a2a4ea701e0bc7b2afb778b1f0c1e4b4d89624.tar.gz
cpython-95a2a4ea701e0bc7b2afb778b1f0c1e4b4d89624.tar.bz2
Tools/scripts/reindent.py _is_ your friend
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/test/test_associate.py120
-rw-r--r--Lib/bsddb/test/test_basics.py14
-rw-r--r--Lib/bsddb/test/test_compare.py52
-rw-r--r--Lib/bsddb/test/test_recno.py46
4 files changed, 116 insertions, 116 deletions
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
index b83b65f..0015b53 100644
--- a/Lib/bsddb/test/test_associate.py
+++ b/Lib/bsddb/test/test_associate.py
@@ -94,12 +94,12 @@ class AssociateErrorTestCase(unittest.TestCase):
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
self.homeDir = homeDir
try:
- os.mkdir(homeDir)
+ os.mkdir(homeDir)
except os.error:
- import glob
- files = glob.glob(os.path.join(self.homeDir, '*'))
- for file in files:
- os.remove(file)
+ import glob
+ files = glob.glob(os.path.join(self.homeDir, '*'))
+ for file in files:
+ os.remove(file)
self.env = db.DBEnv()
self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
@@ -126,17 +126,17 @@ class AssociateErrorTestCase(unittest.TestCase):
# dupDB has been configured to allow duplicates, it can't
# associate with a secondary. BerkeleyDB will return an error.
- try:
- def f(a,b): return a+b
- dupDB.associate(secDB, f)
- except db.DBError:
- # good
- secDB.close()
- dupDB.close()
- else:
- secDB.close()
- dupDB.close()
- self.fail("DBError exception was expected")
+ try:
+ def f(a,b): return a+b
+ dupDB.associate(secDB, f)
+ except db.DBError:
+ # good
+ secDB.close()
+ dupDB.close()
+ else:
+ secDB.close()
+ dupDB.close()
+ self.fail("DBError exception was expected")
@@ -153,12 +153,12 @@ class AssociateTestCase(unittest.TestCase):
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
self.homeDir = homeDir
try:
- os.mkdir(homeDir)
+ os.mkdir(homeDir)
except os.error:
- import glob
- files = glob.glob(os.path.join(self.homeDir, '*'))
- for file in files:
- os.remove(file)
+ import glob
+ files = glob.glob(os.path.join(self.homeDir, '*'))
+ for file in files:
+ os.remove(file)
self.env = db.DBEnv()
self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
@@ -178,22 +178,22 @@ class AssociateTestCase(unittest.TestCase):
d.put(key, string.join(value, '|'), txn=txn)
def createDB(self, txn=None):
- self.cur = None
- self.secDB = 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,
+ 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,
+ else:
+ self.primary.open(self.filename, "primary", self.dbtype,
db.DB_CREATE | db.DB_THREAD | self.dbFlags)
def closeDB(self):
- if self.cur:
- self.cur.close()
- if self.secDB:
- self.secDB.close()
+ if self.cur:
+ self.cur.close()
+ if self.secDB:
+ self.secDB.close()
self.primary.close()
def getDB(self):
@@ -294,7 +294,7 @@ class AssociateTestCase(unittest.TestCase):
# all items accounted for EXCEPT for 1 with "Blues" genre
assert count == len(musicdata)-1
- self.cur = None
+ self.cur = None
def getGenre(self, priKey, priData):
assert type(priData) == type("")
@@ -327,14 +327,14 @@ class AssociateBTreeTxnTestCase(AssociateBTreeTestCase):
dbFlags = 0
def txn_finish_test(self, sDB, txn):
- try:
- self.finish_test(sDB, txn=txn)
- finally:
- if self.cur:
- self.cur.close()
- self.cur = None
- if txn:
- txn.commit()
+ try:
+ self.finish_test(sDB, txn=txn)
+ finally:
+ if self.cur:
+ self.cur.close()
+ self.cur = None
+ if txn:
+ txn.commit()
def test13_associate_in_transaction(self):
if verbose:
@@ -342,26 +342,26 @@ class AssociateBTreeTxnTestCase(AssociateBTreeTestCase):
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)
+ 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.addDataToDB(self.getDB(), txn=txn)
+ except:
+ txn.abort()
+ raise
- self.txn_finish_test(self.secDB, txn=txn)
+ self.txn_finish_test(self.secDB, txn=txn)
#----------------------------------------------------------------------
@@ -454,8 +454,8 @@ def test_suite():
suite.addTest(unittest.makeSuite(AssociateBTreeTestCase))
suite.addTest(unittest.makeSuite(AssociateRecnoTestCase))
- if db.version() >= (4, 1):
- suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))
+ if db.version() >= (4, 1):
+ suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))
suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase))
suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase))
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index d3bbb4f..844d6b7 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -397,14 +397,14 @@ class BasicTestCase(unittest.TestCase):
try:
rec = c.current()
except db.DBKeyEmptyError, val:
- if get_raises_error:
- assert val[0] == db.DB_KEYEMPTY
- if verbose: print val
- else:
- self.fail("unexpected DBKeyEmptyError")
+ if get_raises_error:
+ assert val[0] == db.DB_KEYEMPTY
+ if verbose: print val
+ else:
+ self.fail("unexpected DBKeyEmptyError")
else:
- if get_raises_error:
- self.fail('DBKeyEmptyError exception expected')
+ if get_raises_error:
+ self.fail('DBKeyEmptyError exception expected')
c.next()
c2 = c.dup(db.DB_POSITION)
diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py
index 225959c..63afb4f 100644
--- a/Lib/bsddb/test/test_compare.py
+++ b/Lib/bsddb/test/test_compare.py
@@ -164,21 +164,21 @@ class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
self.finishTest ()
def verifyStderr(self, method, successRe):
- """
- Call method() while capturing sys.stderr output internally and
- call self.fail() if successRe.search() does not match the stderr
- output. This is used to test for uncatchable exceptions.
- """
- stdErr = sys.stderr
- sys.stderr = StringIO()
- try:
- method()
- finally:
- temp = sys.stderr
- sys.stderr = stdErr
- errorOut = temp.getvalue()
- if not successRe.search(errorOut):
- self.fail("unexpected stderr output:\n"+errorOut)
+ """
+ Call method() while capturing sys.stderr output internally and
+ call self.fail() if successRe.search() does not match the stderr
+ output. This is used to test for uncatchable exceptions.
+ """
+ stdErr = sys.stderr
+ sys.stderr = StringIO()
+ try:
+ method()
+ finally:
+ temp = sys.stderr
+ sys.stderr = stdErr
+ errorOut = temp.getvalue()
+ if not successRe.search(errorOut):
+ self.fail("unexpected stderr output:\n"+errorOut)
def _test_compare_function_exception (self):
self.startTest ()
@@ -188,15 +188,15 @@ class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
return 0
raise RuntimeError, "i'm a naughty comparison function"
self.createDB (bad_comparator)
- #print "\n*** test should print 2 uncatchable tracebacks ***"
- self.addDataToDB (['a', 'b', 'c']) # this should raise, but...
- self.finishTest ()
+ #print "\n*** test should print 2 uncatchable tracebacks ***"
+ self.addDataToDB (['a', 'b', 'c']) # this should raise, but...
+ self.finishTest ()
def test_compare_function_exception(self):
- self.verifyStderr(
- self._test_compare_function_exception,
- re.compile('(^RuntimeError:.* naughty.*){2}', re.M|re.S)
- )
+ self.verifyStderr(
+ self._test_compare_function_exception,
+ re.compile('(^RuntimeError:.* naughty.*){2}', re.M|re.S)
+ )
def _test_compare_function_bad_return (self):
self.startTest ()
@@ -211,10 +211,10 @@ class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
self.finishTest ()
def test_compare_function_bad_return(self):
- self.verifyStderr(
- self._test_compare_function_bad_return,
- re.compile('(^TypeError:.* return an int.*){2}', re.M|re.S)
- )
+ self.verifyStderr(
+ self._test_compare_function_bad_return,
+ re.compile('(^TypeError:.* return an int.*){2}', re.M|re.S)
+ )
def test_cannot_assign_twice (self):
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index a46a0c5..f1ea56a 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -35,8 +35,8 @@ class SimpleRecnoTestCase(unittest.TestCase):
def test01_basic(self):
d = db.DB()
- get_returns_none = d.set_get_returns_none(2)
- d.set_get_returns_none(get_returns_none)
+ get_returns_none = d.set_get_returns_none(2)
+ d.set_get_returns_none(get_returns_none)
d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
@@ -69,13 +69,13 @@ class SimpleRecnoTestCase(unittest.TestCase):
else:
self.fail("expected exception")
- # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
- try:
- d.has_key(0)
- except db.DBError, val:
- pass
- else:
- self.fail("has_key did not raise a proper exception")
+ # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
+ try:
+ d.has_key(0)
+ except db.DBError, val:
+ pass
+ else:
+ self.fail("has_key did not raise a proper exception")
try:
data = d[100]
@@ -84,13 +84,13 @@ class SimpleRecnoTestCase(unittest.TestCase):
else:
self.fail("expected exception")
- try:
- data = d.get(100)
- except db.DBNotFoundError, val:
- if get_returns_none:
- self.fail("unexpected exception")
- else:
- assert data == None
+ try:
+ data = d.get(100)
+ except db.DBNotFoundError, val:
+ if get_returns_none:
+ self.fail("unexpected exception")
+ else:
+ assert data == None
keys = d.keys()
if verbose:
@@ -178,14 +178,14 @@ class SimpleRecnoTestCase(unittest.TestCase):
try:
d.get(99)
except db.DBKeyEmptyError, val:
- if get_returns_none:
- self.fail("unexpected DBKeyEmptyError exception")
- else:
- assert val[0] == db.DB_KEYEMPTY
- if verbose: print val
+ if get_returns_none:
+ self.fail("unexpected DBKeyEmptyError exception")
+ else:
+ assert val[0] == db.DB_KEYEMPTY
+ if verbose: print val
else:
- if not get_returns_none:
- self.fail("expected exception")
+ if not get_returns_none:
+ self.fail("expected exception")
rec = c.set(40)
while rec: