]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_bsddb185.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_bsddb185.py
CommitLineData
4710c53d 1"""Tests for the bsddb185 module.\r
2\r
3The file 185test.db found in Lib/test/ is for testing purposes with this\r
4testing suite.\r
5\r
6"""\r
7from test.test_support import run_unittest, findfile, import_module\r
8import unittest\r
9bsddb185 = import_module('bsddb185', deprecated=True)\r
10import anydbm\r
11import whichdb\r
12import os\r
13import tempfile\r
14import shutil\r
15\r
16class Bsddb185Tests(unittest.TestCase):\r
17\r
18 def test_open_existing_hash(self):\r
19 # Verify we can open a file known to be a hash v2 file\r
20 db = bsddb185.hashopen(findfile("185test.db"))\r
21 self.assertEqual(db["1"], "1")\r
22 db.close()\r
23\r
24 def test_whichdb(self):\r
25 # Verify that whichdb correctly sniffs the known hash v2 file\r
26 self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")\r
27\r
28 def test_anydbm_create(self):\r
29 # Verify that anydbm.open does *not* create a bsddb185 file\r
30 tmpdir = tempfile.mkdtemp()\r
31 try:\r
32 dbfile = os.path.join(tmpdir, "foo.db")\r
33 anydbm.open(dbfile, "c").close()\r
34 ftype = whichdb.whichdb(dbfile)\r
35 self.assertNotEqual(ftype, "bsddb185")\r
36 finally:\r
37 shutil.rmtree(tmpdir)\r
38\r
39def test_main():\r
40 run_unittest(Bsddb185Tests)\r
41\r
42if __name__ == "__main__":\r
43 test_main()\r