From f62fb02b320b41fc715f463b59a72f67415ee823 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Tue, 16 May 2023 13:58:40 +0900 Subject: [PATCH 1/3] gh-104469: Update README.txt for _testcapi Co-authored-by: Erlend E. Aasland --- Modules/_testcapi/README.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/_testcapi/README.txt b/Modules/_testcapi/README.txt index 134b6efc638095..fee4c30733f297 100644 --- a/Modules/_testcapi/README.txt +++ b/Modules/_testcapi/README.txt @@ -1,3 +1,10 @@ Tests in this directory are compiled into the _testcapi extension. The main file for the extension is Modules/_testcapimodule.c, which calls `_PyTestCapi_Init_*` from these functions. + +General guideline for writing test C API. +* Use clinic tool as possible. +* Add a newline between the the argument spec and the docstring. +* If a test decription is needed, make sure the added docstring clearly and succinctly describes purpose of the function. +* DRY, use the clone feature of Argument Clinic. +* Try to avoid adding new interned strings; reuse existing parameter names if possible and use the `as` feature to override the C name. From 62531efd3bcaeb77e13c083e384b5615786f7fe8 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Tue, 16 May 2023 14:00:28 +0900 Subject: [PATCH 2/3] nit --- Modules/_testcapi/README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_testcapi/README.txt b/Modules/_testcapi/README.txt index fee4c30733f297..3e69f71fc7f619 100644 --- a/Modules/_testcapi/README.txt +++ b/Modules/_testcapi/README.txt @@ -2,7 +2,7 @@ Tests in this directory are compiled into the _testcapi extension. The main file for the extension is Modules/_testcapimodule.c, which calls `_PyTestCapi_Init_*` from these functions. -General guideline for writing test C API. +General guideline when writing test code for C API. * Use clinic tool as possible. * Add a newline between the the argument spec and the docstring. * If a test decription is needed, make sure the added docstring clearly and succinctly describes purpose of the function. From 03936c861c59db32f18fba28788e0e6d3e478aeb Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Wed, 17 May 2023 00:01:51 +0900 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Erlend E. Aasland Co-authored-by: Kirill Podoprigora --- Modules/_testcapi/README.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/_testcapi/README.txt b/Modules/_testcapi/README.txt index 3e69f71fc7f619..8a65e7abf77009 100644 --- a/Modules/_testcapi/README.txt +++ b/Modules/_testcapi/README.txt @@ -3,8 +3,8 @@ The main file for the extension is Modules/_testcapimodule.c, which calls `_PyTestCapi_Init_*` from these functions. General guideline when writing test code for C API. -* Use clinic tool as possible. -* Add a newline between the the argument spec and the docstring. -* If a test decription is needed, make sure the added docstring clearly and succinctly describes purpose of the function. +* Use Argument Clinic to minimise the amount of boilerplate code. +* Add a newline between the argument spec and the docstring. +* If a test description is needed, make sure the added docstring clearly and succinctly describes purpose of the function. * DRY, use the clone feature of Argument Clinic. -* Try to avoid adding new interned strings; reuse existing parameter names if possible and use the `as` feature to override the C name. +* Try to avoid adding new interned strings; reuse existing parameter names if possible. Use the `as` feature of Argument Clinic to override the C variable name, if needed.