]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-124486: Fix test_whichdb_ndbm in test_dbm on NetBSD (GH-136335) (GH-136379)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Jul 2025 12:50:40 +0000 (14:50 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Jul 2025 12:50:40 +0000 (12:50 +0000)
On NetBSD, ndbm.open() does not fail for empty file.
(cherry picked from commit b7aa2a4b4df697db6ea45a555eeb3fefa5ca5bd4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_dbm.py

index 4be7c5649da68aa71103b117ea5da991723b3ed2..6785aa273ac7db197c76118b18ab5db89b1e1d22 100644 (file)
@@ -213,7 +213,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)]