mirror of
https://github.com/python/cpython.git
synced 2025-10-29 12:44:56 +00:00
gh-129928: Raise more accurate exception for incorrect sqlite3 UDF creation (#129941)
Consistently raise ProgrammingError if the user tries to create an UDF with an invalid number of parameters.
This commit is contained in:
parent
0dbe543d70
commit
3a2e7aacf6
3 changed files with 29 additions and 6 deletions
|
|
@ -171,7 +171,7 @@ def tearDown(self):
|
|||
self.con.close()
|
||||
|
||||
def test_func_error_on_create(self):
|
||||
with self.assertRaises(sqlite.OperationalError):
|
||||
with self.assertRaisesRegex(sqlite.ProgrammingError, "not -100"):
|
||||
self.con.create_function("bla", -100, lambda x: 2*x)
|
||||
|
||||
def test_func_too_many_args(self):
|
||||
|
|
@ -507,9 +507,8 @@ def test_win_sum_int(self):
|
|||
self.assertEqual(self.cur.fetchall(), self.expected)
|
||||
|
||||
def test_win_error_on_create(self):
|
||||
self.assertRaises(sqlite.ProgrammingError,
|
||||
self.con.create_window_function,
|
||||
"shouldfail", -100, WindowSumInt)
|
||||
with self.assertRaisesRegex(sqlite.ProgrammingError, "not -100"):
|
||||
self.con.create_window_function("shouldfail", -100, WindowSumInt)
|
||||
|
||||
@with_tracebacks(BadWindow)
|
||||
def test_win_exception_in_method(self):
|
||||
|
|
@ -638,7 +637,7 @@ def tearDown(self):
|
|||
self.con.close()
|
||||
|
||||
def test_aggr_error_on_create(self):
|
||||
with self.assertRaises(sqlite.OperationalError):
|
||||
with self.assertRaisesRegex(sqlite.ProgrammingError, "not -100"):
|
||||
self.con.create_function("bla", -100, AggrSum)
|
||||
|
||||
@with_tracebacks(AttributeError, msg_regex="AggrNoStep")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue