MCPcopy Create free account
hub / github.com/pytorch/pytorch / testSimple

Method testSimple

caffe2/python/db_test.py:25–46  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

23 ]
24
25 def testSimple(self):
26 db = workspace.C.create_db(
27 "minidb", self.file_name, workspace.C.Mode.write)
28
29 for key, value in self.data:
30 transaction = db.new_transaction()
31 transaction.put(key, value)
32 del transaction
33
34 del db # should close DB
35
36 db = workspace.C.create_db(
37 "minidb", self.file_name, workspace.C.Mode.read)
38 cursor = db.new_cursor()
39 data = []
40 while cursor.valid():
41 data.append((cursor.key(), cursor.value()))
42 cursor.next() # noqa: B305
43 del cursor
44
45 db.close() # test explicit db closer
46 self.assertEqual(data, self.data)

Callers

nothing calls this directly

Calls 8

validMethod · 0.80
putMethod · 0.45
appendMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45
nextMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected