]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-124486: Fix test_whichdb_ndbm in test_dbm on NetBSD (GH-136335)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 7 Jul 2025 12:14:17 +0000 (15:14 +0300)
committerGitHub <noreply@github.com>
Mon, 7 Jul 2025 12:14:17 +0000 (15:14 +0300)
On NetBSD, ndbm.open() does not fail for empty file.

Lib/test/test_dbm.py

index 7e8d78b89405abdf2951175dd36a3da773aa4fdd..ae9faabd536a6cbf6bd4504de261d41136d33639 100644 (file)
@@ -274,7 +274,8 @@ class WhichDBTestCase(unittest.TestCase):
     @unittest.skipUnless(ndbm, reason='Test requires ndbm')
     def test_whichdb_ndbm(self):
         # Issue 17198: check that ndbm which is referenced in whichdb is defined
-        with open(_fname + '.db', 'wb'): pass
+        with open(_fname + '.db', 'wb') as f:
+            f.write(b'spam')
         _bytes_fname = os.fsencode(_fname)
         fnames = [_fname, os_helper.FakePath(_fname),
                   _bytes_fname, os_helper.FakePath(_bytes_fname)]