diff options
author | Erlend E. Aasland <erlend@python.org> | 2023-08-28 13:32:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-28 13:32:07 (GMT) |
commit | 4116592b6f014a2720e9b09e2c8dec4bf4b4cd8f (patch) | |
tree | 676911a42fc5d148e3b118d9998ebfba6a804a9a /Lib/test/test_sqlite3 | |
parent | bc5356bb5d7e3eda44128e89a695c05066e0840b (diff) | |
download | cpython-4116592b6f014a2720e9b09e2c8dec4bf4b4cd8f.zip cpython-4116592b6f014a2720e9b09e2c8dec4bf4b4cd8f.tar.gz cpython-4116592b6f014a2720e9b09e2c8dec4bf4b4cd8f.tar.bz2 |
gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs (#108281)
Deprecate passing name, number of arguments, and the callable as keyword
arguments, for the following sqlite3.Connection APIs:
- create_function(name, nargs, callable, ...)
- create_aggregate(name, nargs, callable)
The affected parameters will become positional-only in Python 3.15.
Diffstat (limited to 'Lib/test/test_sqlite3')
-rw-r--r-- | Lib/test/test_sqlite3/test_userfunctions.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_userfunctions.py b/Lib/test/test_sqlite3/test_userfunctions.py index 5d12636..d86b8c6 100644 --- a/Lib/test/test_sqlite3/test_userfunctions.py +++ b/Lib/test/test_sqlite3/test_userfunctions.py @@ -421,6 +421,29 @@ class FunctionTests(unittest.TestCase): self.assertRaisesRegex(sqlite.OperationalError, msg, self.con.execute, "select badreturn()") + def test_func_keyword_args(self): + regex = ( + r"Passing keyword arguments 'name', 'narg' and 'func' to " + r"_sqlite3.Connection.create_function\(\) is deprecated. " + r"Parameters 'name', 'narg' and 'func' will become " + r"positional-only in Python 3.15." + ) + + def noop(): + return None + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.create_function("noop", 0, func=noop) + self.assertEqual(cm.filename, __file__) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.create_function("noop", narg=0, func=noop) + self.assertEqual(cm.filename, __file__) + + with self.assertWarnsRegex(DeprecationWarning, regex) as cm: + self.con.create_function(name="noop", narg=0, func=noop) + self.assertEqual(cm.filename, __file__) + class WindowSumInt: def __init__(self): |