Skip to content

Add test for opening an SQLite with bytes path #136331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add test for opening an SQLite with bytes path
  • Loading branch information
serhiy-storchaka committed Jul 6, 2025
commit e762405097b42ee6fac17f92fc6df437e7972d37
8 changes: 8 additions & 0 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,14 @@ def test_deserialize_corrupt_database(self):
class OpenTests(unittest.TestCase):
_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):
""" Checks that we can successfully connect to a database using an object that
is PathLike, i.e. has __fspath__(). """
Expand Down
Loading