Skip to content

Commit f291888

Browse files
authored
bpo-33901: Fix test_gdbm for gdbm 1.15 (GH-7798) (GH-7818)
Fix test_gdbm.test_reorganize() on macOS with gdbm 1.15: add a larger value to make sure that the file size changes. (cherry picked from commit 13c79c6)
1 parent b2dd5f1 commit f291888

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Lib/test/test_gdbm.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,22 @@ def test_reorganize(self):
6262
self.g = gdbm.open(filename, 'c')
6363
size0 = os.path.getsize(filename)
6464

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

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

7377
self.g.reorganize()
7478
size2 = os.path.getsize(filename)
75-
self.assertTrue(size1 > size2 >= size0)
79+
self.assertLess(size2, size1)
80+
self.assertGreaterEqual(size2, size0)
7681

7782

7883
def test_main():
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix test_gdbm on macOS with gdbm 1.15: add a larger value to make sure that
2+
the file size changes.

0 commit comments

Comments
 (0)