Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9b3f0f7
gh-116303: Skip some sqlite3 tests if testcapi is unavailable
erlend-aasland Mar 4, 2024
0f6f74e
Skip more tests
erlend-aasland Mar 4, 2024
2f750c3
Split up sqlite3 tests
erlend-aasland Mar 4, 2024
7c4477d
Amend previous commit
erlend-aasland Mar 4, 2024
a9c6f62
Pull in main
erlend-aasland Mar 4, 2024
cdc6df4
Use import_helper iso. requires_limited_api
erlend-aasland Mar 5, 2024
d05dcd7
More skips
erlend-aasland Mar 5, 2024
cb7cff4
Fix gc and weakref tests
erlend-aasland Mar 5, 2024
ad5e3b6
Remove local debug stuff
erlend-aasland Mar 5, 2024
cdb8bf4
Fix test_os
erlend-aasland Mar 5, 2024
e4a30b0
Fixup stable_abi.py
erlend-aasland Mar 5, 2024
fabb007
Fixup run_in_subinterp
erlend-aasland Mar 5, 2024
c51dafa
Fixup test_call
erlend-aasland Mar 5, 2024
c3f9c99
Fixup test_audit
erlend-aasland Mar 5, 2024
fde9548
Fix some _testsinglephase issues
erlend-aasland Mar 5, 2024
ea72ced
Address review: use setUpClass in test_call; don't skip everything
erlend-aasland Mar 5, 2024
628896c
Address review: no need to skip in tearDown
erlend-aasland Mar 5, 2024
88c6739
Address review: check import at the top of test_threading.test_frame_…
erlend-aasland Mar 5, 2024
c02cd6f
Fixup some test.support helpers
erlend-aasland Mar 5, 2024
d49532b
Fixup test_coroutines
erlend-aasland Mar 5, 2024
2427111
Fixup test_threading
erlend-aasland Mar 5, 2024
25d0999
Fixup test_repl
erlend-aasland Mar 5, 2024
bdd8cff
Fixup test_monitoring
erlend-aasland Mar 5, 2024
ee9fa51
Amend test_embed
erlend-aasland Mar 5, 2024
a47c5ff
Amend test_audit
erlend-aasland Mar 5, 2024
d84a5c4
Fix test_socket
erlend-aasland Mar 5, 2024
e877ffb
Resolve test_exceptions nicer
erlend-aasland Mar 5, 2024
1ec0c66
Merge branch 'main' into sqlite/testcapi
erlend-aasland Mar 5, 2024
afa58a9
Use import_helper in test_importlib
erlend-aasland Mar 5, 2024
760c6cb
Fixup test_embed
erlend-aasland Mar 5, 2024
d7f060a
Pull in main
erlend-aasland Mar 5, 2024
a1106b7
Revert spurious docs change
erlend-aasland Mar 5, 2024
db45852
Workaround: use a different test module name in test_module_resources
erlend-aasland Mar 5, 2024
ccd8bea
gh-116307: Create a new import helper 'isolated modules' and use that…
jaraco Mar 6, 2024
f80f75e
Merge branch 'main' into sqlite/testcapi
erlend-aasland Mar 6, 2024
39d135d
Revert "Workaround: use a different test module name in test_module_r…
erlend-aasland Mar 6, 2024
13c4829
Revert another spurious test_importlib change
erlend-aasland Mar 6, 2024
31e19a7
Fix test_embed
erlend-aasland Mar 7, 2024
45e0586
Pull in main
erlend-aasland Mar 7, 2024
a148fb5
Remove useless import from test_embed
erlend-aasland Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolve test_exceptions nicer
  • Loading branch information
erlend-aasland committed Mar 5, 2024
commit e877ffb04d45e6ddd77f75dcdaa2f17bda46ddbf
28 changes: 16 additions & 12 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
from test import support

try:
import _testcapi
from _testcapi import INT_MAX
except ImportError:
_testcapi = None
INT_MAX = 2**31 - 1


Expand Down Expand Up @@ -344,8 +346,8 @@ def __init__(self_):
class InvalidException:
pass

@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_capi1():
_testcapi = import_module("_testcapi")
try:
_testcapi.raise_exception(BadException, 1)
except TypeError as err:
Expand All @@ -355,8 +357,8 @@ def test_capi1():
else:
self.fail("Expected exception")

@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_capi2():
_testcapi = import_module("_testcapi")
try:
_testcapi.raise_exception(BadException, 0)
except RuntimeError as err:
Expand All @@ -369,8 +371,8 @@ def test_capi2():
else:
self.fail("Expected exception")

@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_capi3():
_testcapi = import_module("_testcapi")
self.assertRaises(SystemError, _testcapi.raise_exception,
InvalidException, 1)

Expand Down Expand Up @@ -1435,8 +1437,8 @@ def gen():
self.assertIn(b'Done.', out)

@cpython_only
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_recursion_normalizing_infinite_exception(self):
import_module("_testcapi")
# Issue #30697. Test that a RecursionError is raised when
# maximum recursion depth has been exceeded when creating
# an exception
Expand Down Expand Up @@ -1504,8 +1506,8 @@ def recurse_in_body_and_except():
# Python built with Py_TRACE_REFS fail with a fatal error in
# _PyRefchain_Trace() on memory allocation error.
@unittest.skipIf(support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build')
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_recursion_normalizing_with_no_memory(self):
import_module("_testcapi")
# Issue #30697. Test that in the abort that occurs when there is no
# memory left and the size of the Python frames stack is greater than
# the size of the list of preallocated MemoryError instances, the
Expand All @@ -1527,14 +1529,15 @@ def recurse(cnt):
self.assertIn(b'MemoryError', err)

@cpython_only
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_MemoryError(self):
# PyErr_NoMemory always raises the same exception instance.
# Check that the traceback is not doubled.
_testcapi = import_module("_testcapi")
import traceback
from _testcapi import raise_memoryerror
def raiseMemError():
try:
_testcapi.raise_memoryerror()
raise_memoryerror()
except MemoryError as e:
tb = e.__traceback__
else:
Expand All @@ -1546,8 +1549,8 @@ def raiseMemError():
self.assertEqual(tb1, tb2)

@cpython_only
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_exception_with_doc(self):
_testcapi = import_module("_testcapi")
doc2 = "This is a test docstring."
doc4 = "This is another test docstring."

Expand Down Expand Up @@ -1586,18 +1589,19 @@ class C(object):
self.assertEqual(error5.__doc__, "")

@cpython_only
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_memory_error_cleanup(self):
# Issue #5437: preallocated MemoryError instances should not keep
# traceback objects alive.
_testcapi = import_module("_testcapi")
from _testcapi import raise_memoryerror
class C:
pass
wr = None
def inner():
nonlocal wr
c = C()
wr = weakref.ref(c)
_testcapi.raise_memoryerror()
raise_memoryerror()
# We cannot use assertRaises since it manually deletes the traceback
try:
inner()
Expand Down Expand Up @@ -1676,8 +1680,8 @@ def test_unhandled(self):
# Python built with Py_TRACE_REFS fail with a fatal error in
# _PyRefchain_Trace() on memory allocation error.
@unittest.skipIf(support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build')
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_memory_error_in_PyErr_PrintEx(self):
import_module("_testcapi")
code = """if 1:
import _testcapi
class C(): pass
Expand Down Expand Up @@ -1795,8 +1799,8 @@ class TestException(MemoryError):

gc_collect()

@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_memory_error_in_subinterp(self):
import_module("_testcapi")
# gh-109894: subinterpreters shouldn't count on last resort memory error
# when MemoryError is raised through PyErr_NoMemory() call,
# and should preallocate memory errors as does the main interpreter.
Expand Down