mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
gh-133595: Clean up sqlite3.Connection APIs (GH-133605)
* All parameters of sqlite3.connect() except "database" are now keyword-only. * The first three parameters of methods create_function() and create_aggregate() are now positional-only. * The first parameter of methods set_authorizer(), set_progress_handler() and set_trace_callback() is now positional-only.
This commit is contained in:
parent
2561e148ec
commit
dcf93c4c93
17 changed files with 117 additions and 445 deletions
|
|
@ -220,16 +220,9 @@ def bad_progress():
|
|||
""")
|
||||
|
||||
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:
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
'takes at least 1 positional argument'):
|
||||
self.con.set_progress_handler(progress_handler=lambda: None, n=1)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
|
||||
class TraceCallbackTests(MemoryDatabaseMixin, unittest.TestCase):
|
||||
|
|
@ -353,16 +346,9 @@ def test_trace_bad_handler(self):
|
|||
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:
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
'takes exactly 1 positional argument'):
|
||||
self.con.set_trace_callback(trace_callback=lambda: None)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue