From: Victor Stinner Date: Tue, 19 Jun 2018 15:37:07 +0000 (+0200) Subject: bpo-33901: Better test_dbm_gnu.test_reorganize() fix (GH-7795) X-Git-Tag: v3.8.0a1~1530 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c44d8e5db6fb9d3847c49e9c9718f2b4cf71f506;p=thirdparty%2FPython%2Fcpython.git bpo-33901: Better test_dbm_gnu.test_reorganize() fix (GH-7795) Fix test_dbm_gnu.test_reorganize() on macOS with gdbm 1.15: add a larger value to make sure that the file size changes. --- diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py index 8d76fc75a8ce..379601ad86de 100644 --- a/Lib/test/test_dbm_gnu.py +++ b/Lib/test/test_dbm_gnu.py @@ -72,9 +72,13 @@ class TestGdbm(unittest.TestCase): 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.assertGreaterEqual(size1, size0) + self.assertGreater(size1, size0) del self.g['x'] # 'size' is supposed to be the same even after deleting an entry. @@ -82,7 +86,7 @@ class TestGdbm(unittest.TestCase): self.g.reorganize() size2 = os.path.getsize(filename) - self.assertLessEqual(size2, size1) + self.assertLess(size2, size1) self.assertGreaterEqual(size2, size0) def test_context_manager(self): diff --git a/Misc/NEWS.d/next/Tests/2018-06-19-14-04-21.bpo-33901.OFW1Sr.rst b/Misc/NEWS.d/next/Tests/2018-06-19-14-04-21.bpo-33901.OFW1Sr.rst index 0ca9b60efb9f..2a2dec3e9fa1 100644 --- a/Misc/NEWS.d/next/Tests/2018-06-19-14-04-21.bpo-33901.OFW1Sr.rst +++ b/Misc/NEWS.d/next/Tests/2018-06-19-14-04-21.bpo-33901.OFW1Sr.rst @@ -1,4 +1,2 @@ -Fix test_dbm_gnu for gdbm 1.15. Using gdbm 1.15, creating a database creates -a file of 16 MiB. Adding a small entry and then modifying the small entry -doesn't change the file size. Modify test_dbm_gnu to be less strict: allow -that the file size doesn't change. +Fix test_dbm_gnu on macOS with gdbm 1.15: add a larger value to make sure that +the file size changes.