From c1323d4b8cb010a06c11bace6e681bea7f895851 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Wed, 10 Nov 2021 19:46:11 +0100 Subject: bpo-45754: Use correct SQLite limit when checking statement length (GH-29489) --- Lib/test/test_sqlite3/test_dbapi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Lib/test/test_sqlite3/test_dbapi.py') diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 6628eee975d..a5ec66fe22a 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -55,7 +55,7 @@ def memory_database(): # Temporarily limit a database connection parameter @contextlib.contextmanager -def cx_limit(cx, category=sqlite.SQLITE_LIMIT_LENGTH, limit=128): +def cx_limit(cx, category=sqlite.SQLITE_LIMIT_SQL_LENGTH, limit=128): try: _prev = cx.setlimit(category, limit) yield limit @@ -495,7 +495,7 @@ class ConnectionTests(unittest.TestCase): prev_limit = self.cx.setlimit(category, new_limit) self.assertEqual(saved_limit, prev_limit) self.assertEqual(self.cx.getlimit(category), new_limit) - msg = "string or blob too big" + msg = "query string is too large" self.assertRaisesRegex(sqlite.DataError, msg, self.cx.execute, "select 1 as '16'") finally: # restore saved limit @@ -1063,9 +1063,9 @@ class ExtensionTests(unittest.TestCase): def test_cursor_executescript_too_large_script(self): msg = "query string is too large" with memory_database() as cx, cx_limit(cx) as lim: - cx.executescript("select 'almost too large'".ljust(lim-1)) + cx.executescript("select 'almost too large'".ljust(lim)) with self.assertRaisesRegex(sqlite.DataError, msg): - cx.executescript("select 'too large'".ljust(lim)) + cx.executescript("select 'too large'".ljust(lim+1)) def test_cursor_executescript_tx_control(self): con = sqlite.connect(":memory:") -- cgit v1.2.3