diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
commit | 458120dd40db6b4df55a4e96b650e16798ef06a0 (patch) | |
tree | 8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/lib/python/test/test_bsddb185.py | |
parent | 3a742c699f6806c1145aea5149bf15de15a0afd7 (diff) |
add hg and python
Diffstat (limited to 'sys/lib/python/test/test_bsddb185.py')
-rw-r--r-- | sys/lib/python/test/test_bsddb185.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/lib/python/test/test_bsddb185.py b/sys/lib/python/test/test_bsddb185.py new file mode 100644 index 000000000..df1ece09c --- /dev/null +++ b/sys/lib/python/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 verbose, run_unittest, findfile +import unittest +import bsddb185 +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() |