MCPcopy Index your code
hub / github.com/python/cpython / test_reorganize

Method test_reorganize

Lib/test/test_dbm_gnu.py:89–108  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 self.g.close()
88
89 def test_reorganize(self):
90 self.g = gdbm.open(filename, 'c')
91 size0 = os.path.getsize(filename)
92
93 # bpo-33901: on macOS with gdbm 1.15, an empty database uses 16 MiB
94 # and adding an entry of 10,000 B has no effect on the file size.
95 # Add size0 bytes to make sure that the file size changes.
96 value_size = max(size0, 10000)
97 self.g['x'] = 'x' * value_size
98 size1 = os.path.getsize(filename)
99 self.assertGreater(size1, size0)
100
101 del self.g['x']
102 # 'size' is supposed to be the same even after deleting an entry.
103 self.assertEqual(os.path.getsize(filename), size1)
104
105 self.g.reorganize()
106 size2 = os.path.getsize(filename)
107 self.assertLess(size2, size1)
108 self.assertGreaterEqual(size2, size0)
109
110 def test_context_manager(self):
111 with gdbm.open(filename, 'c') as db:

Callers

nothing calls this directly

Calls 6

assertGreaterMethod · 0.80
assertGreaterEqualMethod · 0.80
openMethod · 0.45
assertEqualMethod · 0.45
reorganizeMethod · 0.45
assertLessMethod · 0.45

Tested by

no test coverage detected