Skip to content

Commit

Permalink
pythongh-116303: Skip some sqlite3 tests if testcapi is unavailable
Browse files Browse the repository at this point in the history
- Lib/test/support/__init__.py
- Lib/test/test_audit.py
- Lib/test/test_gdb/test_misc.py
- Lib/test/test_inspect/test_inspect.py
- Lib/test/test_pydoc/test_pydoc.py
  • Loading branch information
erlend-aasland committed Mar 4, 2024
1 parent cfbdce7 commit fc76e3b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Lib/test/test_sqlite3/test_dbapi.py
Expand Up @@ -31,11 +31,10 @@

from test.support import (
SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess,
is_apple, is_emscripten, is_wasi
is_apple, is_emscripten, is_wasi, import_helper
)
from test.support import gc_collect
from test.support import threading_helper
from _testcapi import INT_MAX, ULLONG_MAX
from os import SEEK_SET, SEEK_CUR, SEEK_END
from test.support.os_helper import TESTFN, TESTFN_UNDECODABLE, unlink, temp_dir, FakePath

Expand Down Expand Up @@ -1200,6 +1199,7 @@ def test_blob_seek_and_tell(self):
self.assertEqual(self.blob.tell(), 40)

def test_blob_seek_error(self):
testcapi = import_helper.import_module("_testcapi")
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"
Expand All @@ -1217,9 +1217,9 @@ def test_blob_seek_error(self):
# Force overflow errors
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()
Expand Down Expand Up @@ -1374,13 +1374,14 @@ def test_blob_mapping_invalid_index_type(self):
self.blob["a"] = b"b"

def test_blob_get_item_error(self):
testcapi = import_helper.import_module("_testcapi")
dataset = [len(self.blob), 105, -105]
for idx in dataset:
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]
self.blob[testcapi.ULLONG_MAX]

# Provoke read error
self.cx.execute("update test set b='aaaa' where rowid=1")
Expand Down

0 comments on commit fc76e3b

Please sign in to comment.