summaryrefslogtreecommitdiff
path: root/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-16 22:12:42 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-16 22:12:42 +0000
commit4710c53dcad1ebf3755f3efb9e80ac24bd72a9b2 (patch)
tree2d17d2388a78082e32f6a97120d707328143543b /AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py
parentcbc6b5e54599c7391ece99ad3c5313f4dd4ddda6 (diff)
downloadedk2-platforms-4710c53dcad1ebf3755f3efb9e80ac24bd72a9b2.tar.xz
AppPkg/Applications/Python: Add Python 2.7.2 sources since the release of Python 2.7.3 made them unavailable from the python.org web site.
These files are a subset of the python-2.7.2.tgz distribution from python.org. Changed files from PyMod-2.7.2 have been copied into the corresponding directories of this tree, replacing the original files in the distribution. Signed-off-by: daryl.mcdaniel@intel.com git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13197 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py')
-rw-r--r--AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py97
1 files changed, 97 insertions, 0 deletions
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py
new file mode 100644
index 0000000000..750a69ee16
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_anydbm.py
@@ -0,0 +1,97 @@
+#! /usr/bin/env python
+"""Test script for the anydbm module
+ based on testdumbdbm.py
+"""
+
+import os
+import unittest
+import glob
+from test import test_support
+
+_fname = test_support.TESTFN
+
+# Silence Py3k warning
+anydbm = test_support.import_module('anydbm', deprecated=True)
+
+def _delete_files():
+ # we don't know the precise name the underlying database uses
+ # so we use glob to locate all names
+ for f in glob.glob(_fname + "*"):
+ try:
+ os.unlink(f)
+ except OSError:
+ pass
+
+class AnyDBMTestCase(unittest.TestCase):
+ _dict = {'0': '',
+ 'a': 'Python:',
+ 'b': 'Programming',
+ 'c': 'the',
+ 'd': 'way',
+ 'f': 'Guido',
+ 'g': 'intended'
+ }
+
+ def __init__(self, *args):
+ unittest.TestCase.__init__(self, *args)
+
+ def test_anydbm_creation(self):
+ f = anydbm.open(_fname, 'c')
+ self.assertEqual(f.keys(), [])
+ for key in self._dict:
+ f[key] = self._dict[key]
+ self.read_helper(f)
+ f.close()
+
+ def test_anydbm_modification(self):
+ self.init_db()
+ f = anydbm.open(_fname, 'c')
+ self._dict['g'] = f['g'] = "indented"
+ self.read_helper(f)
+ f.close()
+
+ def test_anydbm_read(self):
+ self.init_db()
+ f = anydbm.open(_fname, 'r')
+ self.read_helper(f)
+ f.close()
+
+ def test_anydbm_keys(self):
+ self.init_db()
+ f = anydbm.open(_fname, 'r')
+ keys = self.keys_helper(f)
+ f.close()
+
+ def read_helper(self, f):
+ keys = self.keys_helper(f)
+ for key in self._dict:
+ self.assertEqual(self._dict[key], f[key])
+
+ def init_db(self):
+ f = anydbm.open(_fname, 'n')
+ for k in self._dict:
+ f[k] = self._dict[k]
+ f.close()
+
+ def keys_helper(self, f):
+ keys = f.keys()
+ keys.sort()
+ dkeys = self._dict.keys()
+ dkeys.sort()
+ self.assertEqual(keys, dkeys)
+ return keys
+
+ def tearDown(self):
+ _delete_files()
+
+ def setUp(self):
+ _delete_files()
+
+def test_main():
+ try:
+ test_support.run_unittest(AnyDBMTestCase)
+ finally:
+ _delete_files()
+
+if __name__ == "__main__":
+ test_main()