Jeroen Demeyer schrieb am 31.08.2018 um 10:49:
On 2018-08-31 10:31, Victor Stinner wrote:
I don't wante to write unit tests with Cython, cffi or anything else, because I really need very thin control on everything.
You don't need "very thin control on *everything*". You need very thin control on specific parts of the testsuite. And that's the nice thing about Cython: you can easily shift the amount of control that you take. You can write the usual unittest classes and test_FOO methods where you don't care much about control but write fine-tuned C code (either using Cython syntax or C syntax) where you do want control.
Totally agree with Jeroen. Cython makes it trivial to integrate with the current CPython testing infrastructure (as I mentioned somewhere else, we're even using doctests for Cython itself), while giving you any freedom you need for fine grained C-level testing.
Cython's test suite is full of examples:
https://github.com/cython/cython/tree/master/tests
Here's a simple PyMalloc test that might be relevant for the case at hand:
https://github.com/cython/cython/blob/master/tests/run/cpython_capi.pyx
And some doctest intensive generator tests:
https://github.com/cython/cython/blob/master/tests/run/generators.pyx
I find doctests a really nice way to write parametrised C tests.
Of course you may have other reasons to not want Cython...
Stefan