The assert function in C does nothing in non-debug builds.
Like assert vs. self.assertTrue in Python, tests (in Modules/_testcapimodule.c, Modules/_testapi/* and similar) should not use assert. They should fail regardless of build settings.
Possible fixes for this kind of issue:
Raise PyExc_AssertionError or similar explicitly
Move the test to Python if possible (or just part of it, but splitting a test up between files has a readability cost)
Ah, _testcapimodule.c has #undef NDEBUG to enable assert. The parts that are being split out just need it too. I'll tie the fix to #93649 rather than this issue.
Activity
pythongh-95783: Use if+PyErr_Format rather than assert in _testcapi/h…
encukou commented on Aug 8, 2022
Ah, _testcapimodule.c has #undef NDEBUG to enable assert. The parts that are being split out just need it too. I'll tie the fix to #93649 rather than this issue.