cpython/Modules/_testcapi
Victor Stinner 48f08fe6c8
[3.12] gh-111495: Add PyFile tests (#129449) (#129477) (#129501)
[3.13] gh-111495: Add PyFile tests (#129449) (#129477)

gh-111495: Add PyFile tests (#129449)

Add tests for the following functions in test_capi.test_file:

* PyFile_FromFd()
* PyFile_GetLine()
* PyFile_NewStdPrinter()
* PyFile_WriteObject()
* PyFile_WriteString()
* PyObject_AsFileDescriptor()

Remove test_embed.StdPrinterTests which became redundant.

(cherry picked from commit 4ca9fc08f8)
(cherry picked from commit 9a59a51733)
2025-01-31 10:27:35 +01:00
..
clinic [3.12] gh-111495: Add PyFile tests (#129449) (#129477) (#129501) 2025-01-31 10:27:35 +01:00
abstract.c
buffer.c
bytearray.c
bytes.c
code.c
codec.c
complex.c
datetime.c
dict.c
docstring.c
eval.c [3.12] gh-111495: Add more tests on PyEval C APIs (#122789) (#128987) (#129023) 2025-01-19 13:51:53 +00:00
exceptions.c [3.12] gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages (GH-126746) (GH-128027) 2024-12-17 14:53:16 +02:00
file.c [3.12] gh-111495: Add PyFile tests (#129449) (#129477) (#129501) 2025-01-31 10:27:35 +01:00
float.c
gc.c
getargs.c
heaptype.c
heaptype_relative.c
immortal.c
import.c [3.12] gh-128911: Add tests on the PyImport C API (GH-128915) (GH-128960) (#128989) 2025-01-19 14:21:55 +01:00
list.c
long.c
mem.c [3.12] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217) (#129221) 2025-01-23 13:29:46 +00:00
numbers.c [3.12] gh-111495: Add tests for PyNumber C API (GH-111996) (#123376) 2024-09-06 00:51:26 +02:00
parts.h [3.12] gh-111495: Add more tests on PyEval C APIs (#122789) (#128987) (#129023) 2025-01-19 13:51:53 +00:00
pyos.c
pytime.c
README.txt
run.c
set.c
structmember.c
sys.c
testcapi_long.h
tuple.c
unicode.c
util.h
vectorcall.c
vectorcall_limited.c
watchers.c

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 when writing test code for C API.
* 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. Use the `as` feature of Argument Clinic to override the C variable name, if needed.