bpo-45243: Use connection limits to simplify sqlite3 tests (GH-29356)

This commit is contained in:
Erlend Egeberg Aasland 2021-11-05 18:19:43 +01:00 committed by GitHub
parent 71e8a3e76a
commit 3d42cd9461
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 21 deletions

View file

@ -31,6 +31,7 @@ import unittest.mock
import sqlite3 as sqlite
from test.support import bigmemtest
from .test_dbapi import cx_limit
def with_tracebacks(strings, traceback=True):
@ -223,6 +224,14 @@ class FunctionTests(unittest.TestCase):
with self.assertRaises(sqlite.OperationalError):
self.con.create_function("bla", -100, lambda x: 2*x)
def test_func_too_many_args(self):
category = sqlite.SQLITE_LIMIT_FUNCTION_ARG
msg = "too many arguments on function"
with cx_limit(self.con, category=category, limit=1):
self.con.execute("select abs(-1)");
with self.assertRaisesRegex(sqlite.OperationalError, msg):
self.con.execute("select max(1, 2)");
def test_func_ref_count(self):
def getfunc():
def f():