summaryrefslogtreecommitdiff
path: root/Lib/test/test_sqlite3/test_regression.py
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-11-05 18:19:43 +0100
committerGitHub <noreply@github.com>2021-11-05 19:19:43 +0200
commit3d42cd9461e60c7427f3793f640cd975fbd99289 (patch)
treedfc35e75ef8c48121bb5cb402a96eda10f62c371 /Lib/test/test_sqlite3/test_regression.py
parent71e8a3e76a32f5eabe20e7fa984f384ca9af6ec6 (diff)
downloadcpython-git-3d42cd9461e60c7427f3793f640cd975fbd99289.tar.gz
bpo-45243: Use connection limits to simplify `sqlite3` tests (GH-29356)
Diffstat (limited to 'Lib/test/test_sqlite3/test_regression.py')
-rw-r--r--Lib/test/test_sqlite3/test_regression.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/Lib/test/test_sqlite3/test_regression.py b/Lib/test/test_sqlite3/test_regression.py
index 3d71809d9c..158f4cf86f 100644
--- a/Lib/test/test_sqlite3/test_regression.py
+++ b/Lib/test/test_sqlite3/test_regression.py
@@ -28,7 +28,8 @@ import weakref
import functools
from test import support
-from .test_dbapi import managed_connect
+from .test_dbapi import memory_database, managed_connect, cx_limit
+
class RegressionTests(unittest.TestCase):
def setUp(self):
@@ -356,17 +357,18 @@ class RegressionTests(unittest.TestCase):
self.assertRaises(UnicodeEncodeError, cur.execute, "select '\ud8ff'")
self.assertRaises(UnicodeEncodeError, cur.execute, "select '\udcff'")
- @unittest.skipUnless(sys.maxsize > 2**32, 'requires 64bit platform')
- @support.bigmemtest(size=2**31, memuse=4, dry_run=False)
- def test_large_sql(self, maxsize):
- # Test two cases: size+1 > INT_MAX and size+1 <= INT_MAX.
- for size in (2**31, 2**31-2):
- con = sqlite.connect(":memory:")
- sql = "select 1".ljust(size)
- self.assertRaises(sqlite.DataError, con, sql)
- cur = con.cursor()
- self.assertRaises(sqlite.DataError, cur.execute, sql)
- del sql
+ def test_large_sql(self):
+ msg = "query string is too large"
+ with memory_database() as cx, cx_limit(cx) as lim:
+ 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):
"""