(self)
| 18 | os_helper.unlink(self.filename + suffix) |
| 19 | |
| 20 | def test_keys(self): |
| 21 | self.d = dbm.ndbm.open(self.filename, 'c') |
| 22 | self.assertEqual(self.d.keys(), []) |
| 23 | self.d['a'] = 'b' |
| 24 | self.d[b'bytes'] = b'data' |
| 25 | self.d['12345678910'] = '019237410982340912840198242' |
| 26 | self.d.keys() |
| 27 | self.assertIn('a', self.d) |
| 28 | self.assertIn(b'a', self.d) |
| 29 | self.assertEqual(self.d[b'bytes'], b'data') |
| 30 | # get() and setdefault() work as in the dict interface |
| 31 | self.assertEqual(self.d.get(b'a'), b'b') |
| 32 | self.assertIsNone(self.d.get(b'xxx')) |
| 33 | self.assertEqual(self.d.get(b'xxx', b'foo'), b'foo') |
| 34 | with self.assertRaises(KeyError): |
| 35 | self.d['xxx'] |
| 36 | self.assertEqual(self.d.setdefault(b'xxx', b'foo'), b'foo') |
| 37 | self.assertEqual(self.d[b'xxx'], b'foo') |
| 38 | self.d.close() |
| 39 | |
| 40 | def test_empty_value(self): |
| 41 | if dbm.ndbm.library == 'Berkeley DB': |
nothing calls this directly
no test coverage detected