MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_dumbdbm_read

Method test_dumbdbm_read

Lib/test/test_dbm_dumb.py:82–97  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

80 self.assertEqual(f[b'xxx'], b'foo')
81
82 def test_dumbdbm_read(self):
83 self.init_db()
84 with contextlib.closing(dumbdbm.open(_fname, 'r')) as f:
85 self.read_helper(f)
86 with self.assertRaisesRegex(dumbdbm.error,
87 'The database is opened for reading only'):
88 f[b'g'] = b'x'
89 with self.assertRaisesRegex(dumbdbm.error,
90 'The database is opened for reading only'):
91 del f[b'a']
92 # get() works as in the dict interface
93 self.assertEqual(f.get(b'a'), self._dict[b'a'])
94 self.assertEqual(f.get(b'xxx', b'foo'), b'foo')
95 self.assertIsNone(f.get(b'xxx'))
96 with self.assertRaises(KeyError):
97 f[b'xxx']
98
99 def test_dumbdbm_keys(self):
100 self.init_db()

Callers

nothing calls this directly

Calls 9

init_dbMethod · 0.95
read_helperMethod · 0.95
closingMethod · 0.80
assertRaisesRegexMethod · 0.80
assertIsNoneMethod · 0.80
openMethod · 0.45
assertEqualMethod · 0.45
getMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected