From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 7 Jul 2025 12:57:37 +0000 (+0200) Subject: [3.14] gh-124486: Fix test_whichdb_ndbm in test_dbm on NetBSD (GH-136335) (GH-136378) X-Git-Tag: v3.14.0b4~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d9c36a7aa6a570de8dea3a30c8eb82b13fcc80a2;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-124486: Fix test_whichdb_ndbm in test_dbm on NetBSD (GH-136335) (GH-136378) On NetBSD, ndbm.open() does not fail for empty file. (cherry picked from commit b7aa2a4b4df697db6ea45a555eeb3fefa5ca5bd4) Co-authored-by: Serhiy Storchaka --- diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py index a10922a403ec..014c190285c4 100644 --- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -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)]