cpython: e91e9b9ba180 (original) (raw)
Mercurial > cpython
changeset 84485:e91e9b9ba180
#17198: merge with 3.3. [#17198]
Ezio Melotti ezio.melotti@gmail.com | |
---|---|
date | Sun, 07 Jul 2013 13:16:05 +0200 |
parents | 2ab2a2bfea49(current diff)65fce1dad331(diff) |
children | a5010de76eda |
files | Lib/dbm/__init__.py Lib/test/test_dbm.py Misc/NEWS |
diffstat | 3 files changed, 24 insertions(+), 2 deletions(-)[+] [-] Lib/dbm/__init__.py 5 Lib/test/test_dbm.py 18 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/dbm/init.py +++ b/Lib/dbm/init.py @@ -44,6 +44,11 @@ class error(Exception): error = (error, OSError) +try:
+ def open(file, flag='r', mode=0o666): """Open or create database at path given by file.
--- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -9,6 +9,11 @@ import test.support
Skip tests if dbm module doesn't exist.
dbm = test.support.import_module('dbm') +try:
+ _fname = test.support.TESTFN # @@ -130,7 +135,7 @@ class WhichDBTestCase(unittest.TestCase) delete_files() f = module.open(_fname, 'c') f.close()
self.assertEqual(name, dbm.whichdb(_fname))[](#l2.19)
self.assertEqual(name, self.dbm.whichdb(_fname))[](#l2.20) # Now add a key[](#l2.21) f = module.open(_fname, 'w')[](#l2.22) f[b"1"] = b"1"[](#l2.23)
@@ -139,7 +144,15 @@ class WhichDBTestCase(unittest.TestCase) # and read it self.assertTrue(f[b"1"] == b"1") f.close()
self.assertEqual(name, dbm.whichdb(_fname))[](#l2.28)
self.assertEqual(name, self.dbm.whichdb(_fname))[](#l2.29)
- @unittest.skipUnless(ndbm, reason='Test requires ndbm')
- def test_whichdb_ndbm(self):
# Issue 17198: check that ndbm which is referenced in whichdb is defined[](#l2.33)
db_file = '{}_ndbm.db'.format(_fname)[](#l2.34)
with open(db_file, 'w'):[](#l2.35)
self.addCleanup(test.support.unlink, db_file)[](#l2.36)
self.assertIsNone(self.dbm.whichdb(db_file[:-3]))[](#l2.37)
def tearDown(self): delete_files() @@ -149,6 +162,7 @@ class WhichDBTestCase(unittest.TestCase) self.filename = test.support.TESTFN self.d = dbm.open(self.filename, 'c') self.d.close()
self.dbm = test.support.import_fresh_module('dbm')[](#l2.45)
def test_keys(self): self.d = dbm.open(self.filename, 'c')
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -142,6 +142,9 @@ Core and Builtins Library ------- +- Issue #17198: Fix a NameError in the dbm module. Patch by Valentina