mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-32922: dbm.open() now encodes filename with the filesystem encoding. (GH-5832)
This commit is contained in:
parent
973cae07d6
commit
6f600ff173
8 changed files with 134 additions and 19 deletions
|
|
@ -281,6 +281,21 @@ class DumbDBMTestCase(unittest.TestCase):
|
|||
self.assertEqual(sorted(f.keys()), sorted(self._dict))
|
||||
f.close() # don't write
|
||||
|
||||
@unittest.skipUnless(support.TESTFN_NONASCII,
|
||||
'requires OS support of non-ASCII encodings')
|
||||
def test_nonascii_filename(self):
|
||||
filename = support.TESTFN_NONASCII
|
||||
for suffix in ['.dir', '.dat', '.bak']:
|
||||
self.addCleanup(support.unlink, filename + suffix)
|
||||
with dumbdbm.open(filename, 'c') as db:
|
||||
db[b'key'] = b'value'
|
||||
self.assertTrue(os.path.exists(filename + '.dat'))
|
||||
self.assertTrue(os.path.exists(filename + '.dir'))
|
||||
with dumbdbm.open(filename, 'r') as db:
|
||||
self.assertEqual(list(db.keys()), [b'key'])
|
||||
self.assertTrue(b'key' in db)
|
||||
self.assertEqual(db[b'key'], b'value')
|
||||
|
||||
def tearDown(self):
|
||||
_delete_files()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue