def test_keys_method(self): db = self.open_db_file() db['one'] = 'bar' db['two'] = 'bar' db['three'] = 'bar' self.assertEqual(set(db.keys()), set([b'one', b'two', b'three'])) db.close()
def test_when_file_does_not_exist(self): path = os.path.join(self.tempdir, 'foo.db') db = semidbm.open(path, 'n') db['foo'] = 'bar' self.assertEqual(db['foo'], b'bar') db.close() # Opening the file again should basically blank out # any existing database. db = semidbm.open(path, 'n') self.assertEqual(list(db.keys()), []) db.close()