Skip to content
Merged
Prev Previous commit
Next Next commit
Address review: test lim-1 and lim
  • Loading branch information
Erlend E. Aasland
Erlend E. Aasland committed Nov 4, 2021
commit 3a75c2db2ef04f64dce62483e0a9e8d6d27018d2
9 changes: 3 additions & 6 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,9 @@ def test_cursor_executescript_with_surrogates(self):
def test_cursor_executescript_too_large_script(self):
msg = "query string is too large"
with memory_database() as cx, cx_limit(cx) as lim:
for sz in lim, lim+1:
with self.subTest(sz=sz):
self.assertRaisesRegex(
sqlite.DataError, msg, cx.executescript,
"create table a(s);".ljust(sz)
)
cx.executescript("select 'almost too large'".ljust(lim-1))
with self.assertRaisesRegex(sqlite.DataError, msg):
cx.executescript("select 'too large'".ljust(lim))

def test_cursor_executescript_tx_control(self):
con = sqlite.connect(":memory:")
Expand Down
16 changes: 9 additions & 7 deletions Lib/test/test_sqlite3/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,15 @@ def test_surrogates(self):
def test_large_sql(self):
msg = "query string is too large"
with memory_database() as cx, cx_limit(cx) as lim:
for sz in lim, lim+1:
with self.subTest(sz=sz):
sql = "select 1".ljust(sz)
self.assertRaisesRegex(sqlite.DataError, msg, cx, sql)
cu = cx.cursor()
self.assertRaisesRegex(sqlite.DataError, msg,
cu.execute, sql)
cu = cx.cursor()

cx("select 1".ljust(lim-1))
# use a different SQL statement; don't reuse from the LRU cache
cu.execute("select 2".ljust(lim-1))

sql = "select 3".ljust(lim)
self.assertRaisesRegex(sqlite.DataError, msg, cx, sql)
self.assertRaisesRegex(sqlite.DataError, msg, cu.execute, sql)

def test_commit_cursor_reset(self):
"""
Expand Down