aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_sqlite3/test_dbapi.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 588272448bb..4182de246a0 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -34,8 +34,7 @@ from test.support import (
is_apple, is_emscripten, is_wasi
)
from test.support import gc_collect
-from test.support import threading_helper
-from _testcapi import INT_MAX, ULLONG_MAX
+from test.support import threading_helper, import_helper
from os import SEEK_SET, SEEK_CUR, SEEK_END
from test.support.os_helper import TESTFN, TESTFN_UNDECODABLE, unlink, temp_dir, FakePath
@@ -1202,7 +1201,6 @@ class BlobTests(unittest.TestCase):
def test_blob_seek_error(self):
msg_oor = "offset out of blob range"
msg_orig = "'origin' should be os.SEEK_SET, os.SEEK_CUR, or os.SEEK_END"
- msg_of = "seek offset results in overflow"
dataset = (
(ValueError, msg_oor, lambda: self.blob.seek(1000)),
@@ -1214,12 +1212,15 @@ class BlobTests(unittest.TestCase):
with self.subTest(exc=exc, msg=msg, fn=fn):
self.assertRaisesRegex(exc, msg, fn)
+ def test_blob_seek_overflow_error(self):
# Force overflow errors
+ msg_of = "seek offset results in overflow"
+ _testcapi = import_helper.import_module("_testcapi")
self.blob.seek(1, SEEK_SET)
with self.assertRaisesRegex(OverflowError, msg_of):
- self.blob.seek(INT_MAX, SEEK_CUR)
+ self.blob.seek(_testcapi.INT_MAX, SEEK_CUR)
with self.assertRaisesRegex(OverflowError, msg_of):
- self.blob.seek(INT_MAX, SEEK_END)
+ self.blob.seek(_testcapi.INT_MAX, SEEK_END)
def test_blob_read(self):
buf = self.blob.read()
@@ -1379,14 +1380,17 @@ class BlobTests(unittest.TestCase):
with self.subTest(idx=idx):
with self.assertRaisesRegex(IndexError, "index out of range"):
self.blob[idx]
- with self.assertRaisesRegex(IndexError, "cannot fit 'int'"):
- self.blob[ULLONG_MAX]
# Provoke read error
self.cx.execute("update test set b='aaaa' where rowid=1")
with self.assertRaises(sqlite.OperationalError):
self.blob[0]
+ def test_blob_get_item_error_bigint(self):
+ _testcapi = import_helper.import_module("_testcapi")
+ with self.assertRaisesRegex(IndexError, "cannot fit 'int'"):
+ self.blob[_testcapi.ULLONG_MAX]
+
def test_blob_set_item_error(self):
with self.assertRaisesRegex(TypeError, "cannot be interpreted"):
self.blob[0] = b"multiple"