From 4710c53dcad1ebf3755f3efb9e80ac24bd72a9b2 Mon Sep 17 00:00:00 2001 From: darylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524> Date: Mon, 16 Apr 2012 22:12:42 +0000 Subject: 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 --- .../Python/Python-2.7.2/Lib/test/test_whichdb.py | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_whichdb.py (limited to 'AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_whichdb.py') diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_whichdb.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_whichdb.py new file mode 100644 index 0000000000..740db7311d --- /dev/null +++ b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_whichdb.py @@ -0,0 +1,68 @@ +#! /usr/bin/env python +"""Test script for the whichdb module + based on test_anydbm.py +""" + +import os +import test.test_support +import unittest +import whichdb +import glob + +_fname = test.test_support.TESTFN + +# Silence Py3k warning +anydbm = test.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 WhichDBTestCase(unittest.TestCase): + # Actual test methods are added to namespace + # after class definition. + def __init__(self, *args): + unittest.TestCase.__init__(self, *args) + + def tearDown(self): + _delete_files() + + def setUp(self): + _delete_files() + +for name in anydbm._names: + # we define a new test method for each + # candidate database module. + try: + # Silence Py3k warning + mod = test.test_support.import_module(name, deprecated=True) + except unittest.SkipTest: + continue + + def test_whichdb_name(self, name=name, mod=mod): + # Check whether whichdb correctly guesses module name + # for databases opened with module mod. + # Try with empty files first + f = mod.open(_fname, 'c') + f.close() + self.assertEqual(name, whichdb.whichdb(_fname)) + # Now add a key + f = mod.open(_fname, 'w') + f["1"] = "1" + f.close() + self.assertEqual(name, whichdb.whichdb(_fname)) + setattr(WhichDBTestCase,"test_whichdb_%s" % name, test_whichdb_name) + +def test_main(): + try: + test.test_support.run_unittest(WhichDBTestCase) + finally: + _delete_files() + +if __name__ == "__main__": + test_main() -- cgit v1.2.3