diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-05-21 13:53:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-21 13:53:58 (GMT) |
commit | d9a48d2b413194f36111aa54df331d60c5bfde3f (patch) | |
tree | f4b7c27ba630388d7fb964c4249dfc0f1d799878 /Lib/test | |
parent | f2aeb3f6f782716d6b8fbff336d6258a24ba021c (diff) | |
download | cpython-d9a48d2b413194f36111aa54df331d60c5bfde3f.zip cpython-d9a48d2b413194f36111aa54df331d60c5bfde3f.tar.gz cpython-d9a48d2b413194f36111aa54df331d60c5bfde3f.tar.bz2 |
[3.11] gh-93044: No longer convert the database argument of sqlite3.connect() to bytes (GH-93046) (GH-93048)
Just pass it to the factory as is.
(cherry picked from commit 14c0d33016a967a98155f2e1615660e9328aef5d)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_sqlite3/test_dbapi.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index eaba391..2949e13 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -685,6 +685,19 @@ class OpenTests(unittest.TestCase): with managed_connect(f"file:{TESTFN}?mode=ro", uri=True) as cx: cx.execute(self._sql) + def test_factory_database_arg(self): + def factory(database, *args, **kwargs): + nonlocal database_arg + database_arg = database + return sqlite.Connection(":memory:", *args, **kwargs) + + for database in (TESTFN, os.fsencode(TESTFN), + FakePath(TESTFN), FakePath(os.fsencode(TESTFN))): + database_arg = None + with sqlite.connect(database, factory=factory): + pass + self.assertEqual(database_arg, database) + def test_database_keyword(self): with sqlite.connect(database=":memory:") as cx: self.assertEqual(type(cx), sqlite.Connection) |