summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-05-06 20:36:57 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-05-06 20:36:57 (GMT)
commit46f4e79aaff73f0720f10c4bc5a9745aec030864 (patch)
tree94afa1f2e5c73d522ff6d2e1066a56211b328786 /Lib
parent823ba28b0d436f83ebfc5b9df0d475e60e8ae5ee (diff)
downloadcpython-46f4e79aaff73f0720f10c4bc5a9745aec030864.zip
cpython-46f4e79aaff73f0720f10c4bc5a9745aec030864.tar.gz
cpython-46f4e79aaff73f0720f10c4bc5a9745aec030864.tar.bz2
test case for bsddb185 module
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bsddb185.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_bsddb185.py b/Lib/test/test_bsddb185.py
new file mode 100644
index 0000000..48a0764
--- /dev/null
+++ b/Lib/test/test_bsddb185.py
@@ -0,0 +1,40 @@
+
+from test.test_support import verbose, run_unittest, findfile
+import unittest
+import bsddb185
+import anydbm
+import whichdb
+import os
+import tempfile
+
+class Bsddb185Tests(unittest.TestCase):
+ def test_open_existing_hash(self):
+ "verify we can open a file known to be a hash v2 file"
+ # do we need to worry about big vs little endian?
+ 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:
+ try:
+ dbfile = os.path.join(tmpdir, "foo.db")
+ anydbm.open(dbfile, "c").close()
+ ftype = whichdb.whichdb(findfile("foo.db"))
+ self.assertNotEqual(ftype, "bsddb185")
+ finally:
+ os.unlink(dbfile)
+ finally:
+ os.rmdir(tmpdir)
+
+def test_main():
+ run_unittest(Bsddb185Tests)
+
+if __name__ == "__main__":
+ test_main()