diff options
author | Erlend E. Aasland <erlend@python.org> | 2023-08-29 22:02:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 22:02:12 +0200 |
commit | 0b0c1d046cac540deefc56ab3c38732bc76f6c56 (patch) | |
tree | ce91d7e770e3b5f204f377a219fc63aa7f53ddac /Lib/test/test_sqlite3/test_userfunctions.py | |
parent | 77e8f233acd39420dc8921960715bf6b29587fee (diff) | |
download | cpython-0b0c1d046cac540deefc56ab3c38732bc76f6c56.tar.gz cpython-0b0c1d046cac540deefc56ab3c38732bc76f6c56.zip |
gh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (#108632)
Deprecate passing the callback callable by keyword for the following
sqlite3.Connection APIs:
- set_authorizer(authorizer_callback)
- set_progress_handler(progress_handler, ...)
- set_trace_callback(trace_callback)
The affected parameters will become positional-only in Python 3.15.
Diffstat (limited to 'Lib/test/test_sqlite3/test_userfunctions.py')
-rw-r--r-- | Lib/test/test_sqlite3/test_userfunctions.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_userfunctions.py b/Lib/test/test_sqlite3/test_userfunctions.py index d86b8c6025f..09019498fd5 100644 --- a/Lib/test/test_sqlite3/test_userfunctions.py +++ b/Lib/test/test_sqlite3/test_userfunctions.py @@ -737,6 +737,27 @@ class AggregateTests(unittest.TestCase): val = cur.fetchone()[0] self.assertEqual(val, txt) + def test_agg_keyword_args(self): + regex = ( + r"Passing keyword arguments 'name', 'n_arg' and 'aggregate_class' to " + r"_sqlite3.Connection.create_aggregate\(\) is deprecated. " + r"Parameters 'name', 'n_arg' and 'aggregate_class' will become " + r"positional-only in Python 3.15." + ) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.create_aggregate("test", 1, aggregate_class=AggrText) + self.assertEqual(cm.filename, __file__) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.create_aggregate("test", n_arg=1, aggregate_class=AggrText) + self.assertEqual(cm.filename, __file__) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.create_aggregate(name="test", n_arg=0, + aggregate_class=AggrText) + self.assertEqual(cm.filename, __file__) + class AuthorizerTests(unittest.TestCase): @staticmethod @@ -779,6 +800,18 @@ class AuthorizerTests(unittest.TestCase): self.con.execute("select * from t2") self.con.execute("select c2 from t1") + def test_authorizer_keyword_args(self): + regex = ( + r"Passing keyword argument 'authorizer_callback' to " + r"_sqlite3.Connection.set_authorizer\(\) is deprecated. " + r"Parameter 'authorizer_callback' will become positional-only in " + r"Python 3.15." + ) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.set_authorizer(authorizer_callback=lambda: None) + self.assertEqual(cm.filename, __file__) + class AuthorizerRaiseExceptionTests(AuthorizerTests): @staticmethod |