aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_sqlite3
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2023-08-15 10:09:56 +0200
committerGitHub <noreply@github.com>2023-08-15 08:09:56 +0000
commit13c36dc9ae5240124932137de4a94d81292c6c5f (patch)
treed0c519b57139c9af90bec3f6df794d37fdaf94b1 /Lib/test/test_sqlite3
parenta482e5bf0022f85424a6308529a9ad51f1bfbb71 (diff)
downloadcpython-13c36dc9ae5240124932137de4a94d81292c6c5f.tar.gz
cpython-13c36dc9ae5240124932137de4a94d81292c6c5f.zip
gh-93057: Deprecate positional use of optional sqlite3.connect() params (#107948)
Diffstat (limited to 'Lib/test/test_sqlite3')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py13
-rw-r--r--Lib/test/test_sqlite3/test_factory.py11
2 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 3f9bd0248a8..c9a9e135393 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -582,6 +582,19 @@ class ConnectionTests(unittest.TestCase):
with self.assertRaisesRegex(sqlite.IntegrityError, "constraint"):
cx.execute("insert into u values(0)")
+ def test_connect_positional_arguments(self):
+ regex = (
+ r"Passing more than 1 positional argument to sqlite3.connect\(\)"
+ " is deprecated. Parameters 'timeout', 'detect_types', "
+ "'isolation_level', 'check_same_thread', 'factory', "
+ "'cached_statements' and 'uri' will become keyword-only "
+ "parameters in Python 3.15."
+ )
+ with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
+ sqlite.connect(":memory:", 1.0)
+ self.assertEqual(cm.filename, __file__)
+
+
class UninitialisedConnectionTests(unittest.TestCase):
def setUp(self):
diff --git a/Lib/test/test_sqlite3/test_factory.py b/Lib/test/test_sqlite3/test_factory.py
index 7c36135ecad..d63589483e1 100644
--- a/Lib/test/test_sqlite3/test_factory.py
+++ b/Lib/test/test_sqlite3/test_factory.py
@@ -66,7 +66,16 @@ class ConnectionFactoryTests(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Factory, self).__init__(*args, **kwargs)
- con = sqlite.connect(":memory:", 5.0, 0, None, True, Factory)
+ regex = (
+ r"Passing more than 1 positional argument to _sqlite3.Connection\(\) "
+ r"is deprecated. Parameters 'timeout', 'detect_types', "
+ r"'isolation_level', 'check_same_thread', 'factory', "
+ r"'cached_statements' and 'uri' will become keyword-only "
+ r"parameters in Python 3.15."
+ )
+ with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
+ con = sqlite.connect(":memory:", 5.0, 0, None, True, Factory)
+ self.assertEqual(cm.filename, __file__)
self.assertIsNone(con.isolation_level)
self.assertIsInstance(con, Factory)