Add test for opening an SQLite with bytes path (GH-136331)

This commit is contained in:
Serhiy Storchaka 2025-08-11 09:16:54 +03:00 committed by GitHub
parent b36d23f58e
commit 1bde13b0e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -630,6 +630,14 @@ def test_deserialize_corrupt_database(self):
class OpenTests(unittest.TestCase): class OpenTests(unittest.TestCase):
_sql = "create table test(id integer)" _sql = "create table test(id integer)"
def test_open_with_bytes_path(self):
path = os.fsencode(TESTFN)
self.addCleanup(unlink, path)
self.assertFalse(os.path.exists(path))
with contextlib.closing(sqlite.connect(path)) as cx:
self.assertTrue(os.path.exists(path))
cx.execute(self._sql)
def test_open_with_path_like_object(self): def test_open_with_path_like_object(self):
""" Checks that we can successfully connect to a database using an object that """ Checks that we can successfully connect to a database using an object that
is PathLike, i.e. has __fspath__(). """ is PathLike, i.e. has __fspath__(). """