mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-116303: Skip test module dependent tests if test modules are unavailable (#117341)
This commit is contained in:
parent
2ec6bb4111
commit
ea94b3b149
57 changed files with 255 additions and 123 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue