Skip to content
Merged
Changes from 1 commit
Commits
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
Add a test case with finalization
  • Loading branch information
Eclips4 committed May 16, 2024
commit ee4dca9cf9ca6f2b1bf9068137ff3480fe977c42
17 changes: 17 additions & 0 deletions Lib/test/test_capi/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ def foo():
warnings[3].startswith(b" foo() # line 9")
)

def test_warn_during_finalization(self):
code = textwrap.dedent('''\
import _testcapi

class Foo:
def __del__(self):
_testcapi.function_set_warning()

ref = Foo()
''')
proc = assert_python_ok("-c", code)
warnings = proc.err.splitlines()
# Due to the finalization of the interpreter, the source will be ommited
# because the ``warnings`` module cannot be imported at this time
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0], b'<sys>:0: RuntimeWarning: Testing PyErr_WarnEx')
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated


class Test_FatalError(unittest.TestCase):

Expand Down