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_hooks.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_hooks.py')
-rw-r--r-- | Lib/test/test_sqlite3/test_hooks.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_hooks.py b/Lib/test/test_sqlite3/test_hooks.py index 33f0af99532..49e72f8fcfb 100644 --- a/Lib/test/test_sqlite3/test_hooks.py +++ b/Lib/test/test_sqlite3/test_hooks.py @@ -219,6 +219,18 @@ class ProgressTests(MemoryDatabaseMixin, unittest.TestCase): create table foo(a, b) """) + def test_progress_handler_keyword_args(self): + regex = ( + r"Passing keyword argument 'progress_handler' to " + r"_sqlite3.Connection.set_progress_handler\(\) is deprecated. " + r"Parameter 'progress_handler' will become positional-only in " + r"Python 3.15." + ) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.set_progress_handler(progress_handler=lambda: None, n=1) + self.assertEqual(cm.filename, __file__) + class TraceCallbackTests(MemoryDatabaseMixin, unittest.TestCase): @@ -340,6 +352,18 @@ class TraceCallbackTests(MemoryDatabaseMixin, unittest.TestCase): cx.set_trace_callback(lambda stmt: 5/0) cx.execute("select 1") + def test_trace_keyword_args(self): + regex = ( + r"Passing keyword argument 'trace_callback' to " + r"_sqlite3.Connection.set_trace_callback\(\) is deprecated. " + r"Parameter 'trace_callback' will become positional-only in " + r"Python 3.15." + ) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.set_trace_callback(trace_callback=lambda: None) + self.assertEqual(cm.filename, __file__) + if __name__ == "__main__": unittest.main() |