summaryrefslogtreecommitdiff
path: root/src/python/stdlib/test/test_bsddb185.py
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-03-22 17:58:52 (GMT)
committer Simon <simon@hardwired.org.uk>2011-03-22 17:58:52 (GMT)
commit2e401babb793238564ca640fc802a52ab7f6c293 (patch)
tree87a9b471e82604e76f96d556f5771322fb31818a /src/python/stdlib/test/test_bsddb185.py
parentc096b2b14a200a0cc0a08cfea839c9e7f4edf22e (diff)
parent04a9cbcb8855e64db660a8c6e23d79114b4afd83 (diff)
downloadpowder-2e401babb793238564ca640fc802a52ab7f6c293.zip
powder-2e401babb793238564ca640fc802a52ab7f6c293.tar.gz
Python console
Diffstat (limited to 'src/python/stdlib/test/test_bsddb185.py')
-rw-r--r--src/python/stdlib/test/test_bsddb185.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/python/stdlib/test/test_bsddb185.py b/src/python/stdlib/test/test_bsddb185.py
new file mode 100644
index 0000000..98102c1
--- /dev/null
+++ b/src/python/stdlib/test/test_bsddb185.py
@@ -0,0 +1,43 @@
+"""Tests for the bsddb185 module.
+
+The file 185test.db found in Lib/test/ is for testing purposes with this
+testing suite.
+
+"""
+from test.test_support import run_unittest, findfile, import_module
+import unittest
+bsddb185 = import_module('bsddb185', deprecated=True)
+import anydbm
+import whichdb
+import os
+import tempfile
+import shutil
+
+class Bsddb185Tests(unittest.TestCase):
+
+ def test_open_existing_hash(self):
+ # Verify we can open a file known to be a hash v2 file
+ db = bsddb185.hashopen(findfile("185test.db"))
+ self.assertEqual(db["1"], "1")
+ db.close()
+
+ def test_whichdb(self):
+ # Verify that whichdb correctly sniffs the known hash v2 file
+ self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
+
+ def test_anydbm_create(self):
+ # Verify that anydbm.open does *not* create a bsddb185 file
+ tmpdir = tempfile.mkdtemp()
+ try:
+ dbfile = os.path.join(tmpdir, "foo.db")
+ anydbm.open(dbfile, "c").close()
+ ftype = whichdb.whichdb(dbfile)
+ self.assertNotEqual(ftype, "bsddb185")
+ finally:
+ shutil.rmtree(tmpdir)
+
+def test_main():
+ run_unittest(Bsddb185Tests)
+
+if __name__ == "__main__":
+ test_main()