Skip to content

[2.7] bpo-33901: Fix test_gdbm for gdbm 1.15 (GH-7798) #7818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Lib/test/test_gdbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ def test_reorganize(self):
self.g = gdbm.open(filename, 'c')
size0 = os.path.getsize(filename)

self.g['x'] = 'x' * 10000
# bpo-33901: on macOS with gdbm 1.15, an empty database uses 16 MiB
# and adding an entry of 10,000 B has no effect on the file size.
# Add size0 bytes to make sure that the file size changes.
value_size = max(size0, 10000)
self.g['x'] = 'x' * value_size
size1 = os.path.getsize(filename)
self.assertTrue(size0 < size1)
self.assertGreater(size1, size0)

del self.g['x']
# 'size' is supposed to be the same even after deleting an entry.
self.assertEqual(os.path.getsize(filename), size1)

self.g.reorganize()
size2 = os.path.getsize(filename)
self.assertTrue(size1 > size2 >= size0)
self.assertLess(size2, size1)
self.assertGreaterEqual(size2, size0)


def test_main():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix test_gdbm on macOS with gdbm 1.15: add a larger value to make sure that
the file size changes.