MCPcopy Create free account
hub / github.com/python/cpython / test_nonascii_filename

Method test_nonascii_filename

Lib/test/test_dbm_ndbm.py:107–118  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

105 @unittest.skipUnless(os_helper.TESTFN_NONASCII,
106 'requires OS support of non-ASCII encodings')
107 def test_nonascii_filename(self):
108 filename = os_helper.TESTFN_NONASCII
109 for suffix in ['', '.pag', '.dir', '.db']:
110 self.addCleanup(os_helper.unlink, filename + suffix)
111 with dbm.ndbm.open(filename, 'c') as db:
112 db[b'key'] = b'value'
113 self.assertTrue(any(os.path.exists(filename + suffix)
114 for suffix in ['', '.pag', '.dir', '.db']))
115 with dbm.ndbm.open(filename, 'r') as db:
116 self.assertEqual(list(db.keys()), [b'key'])
117 self.assertTrue(b'key' in db)
118 self.assertEqual(db[b'key'], b'value')
119
120 def test_nonexisting_file(self):
121 nonexisting_file = 'nonexisting-file'

Callers

nothing calls this directly

Calls 8

listClass · 0.85
addCleanupMethod · 0.80
assertTrueMethod · 0.80
anyFunction · 0.50
openMethod · 0.45
existsMethod · 0.45
assertEqualMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected