summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dbm_dumb.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-02-26 14:02:22 (GMT)
committerGitHub <noreply@github.com>2018-02-26 14:02:22 (GMT)
commit6f600ff1734ca2fdcdd37a809adf8130f0d8cc4e (patch)
tree3dc8ecabed25ffe13d7e79630a9eea9c3c8f3177 /Lib/test/test_dbm_dumb.py
parent973cae07d6ce7f5a93bd9cd3bcb724a96cfe14e9 (diff)
downloadcpython-6f600ff1734ca2fdcdd37a809adf8130f0d8cc4e.zip
cpython-6f600ff1734ca2fdcdd37a809adf8130f0d8cc4e.tar.gz
cpython-6f600ff1734ca2fdcdd37a809adf8130f0d8cc4e.tar.bz2
bpo-32922: dbm.open() now encodes filename with the filesystem encoding. (GH-5832)
Diffstat (limited to 'Lib/test/test_dbm_dumb.py')
-rw-r--r--Lib/test/test_dbm_dumb.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index 21f29af..652a355 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -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()