[Python-Dev] Testing C API

Serhiy Storchaka storchaka at gmail.com
Sun Jul 29 07:53:10 EDT 2018


Currently C API is not completely covered by tests. Tests for particular 
parts of C API are scattered through different files. There are files 
completely purposed for testing C API (like test_capi.py, 
test_getargs2.py), there are classes (usually having "CAPI" in the name) 
in different files for testing C API specific for unicode, marshal. 
Argument parsing tests are split between two files, test_capi.py, 
test_getargs2.py.

I need to add new tests for new features, and I'm going to add new tests 
for existing C API. But first I'm going to reorganize tests. Add a new 
directory Lib/test/test_capi, and move all C API tests into it, grouped 
by function prefixes. test_getargs.py for testing PyArg_*(), 
test_unicode.py for testing PyUnicode_*(), etc. Tests that use the 
_testcapi module, but don't test specific C API, will left on place.

The benefit is that it will be easier to run all C API tests at once, 
and only them, and it will be clearer what C API is covered by tests. 
The disadvantage is that you will need to run several files for testing 
marshal for example.

What are your thoughts?



More information about the Python-Dev mailing list