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)
- Even
Py_FatalError would be better than assert
The
assertfunction in C does nothing in non-debug builds.Like
assertvs.self.assertTruein Python, tests (inModules/_testcapimodule.c,Modules/_testapi/*and similar) should not useassert. They should fail regardless of build settings.Possible fixes for this kind of issue:
PyExc_AssertionErroror similar explicitlyPy_FatalErrorwould be better thanassert