cpython/Modules/_testcapi
Miss Islington (bot) 33d1cfffe1
[3.12] gh-117968: Make the test for closed file more safe in the C API tests (GH-118230) (GH-118266)
The behavior of fileno() after fclose() is undefined, but it is the only
practical way to check whether the file was closed.
Only test this on the known platforms (Linux, Windows, macOS), where we
already tested that it works.
(cherry picked from commit 546cbcfa0e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-04-25 05:16:43 +00:00
..
clinic [3.12] gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918) (#108134) 2023-08-20 23:07:24 +02:00
abstract.c [3.12] Add more C API tests (GH-112522) (GH-112525) 2023-11-29 22:02:57 +02:00
buffer.c gh-102500: Implement PEP 688 (#102521) 2023-05-04 07:59:46 -07:00
bytearray.c [3.12] gh-111495: Add tests for PyBytes and PyByteArray C API (GH-111496) (GH-111607) 2023-11-01 18:23:39 +00:00
bytes.c [3.12] gh-111495: Add tests for PyBytes and PyByteArray C API (GH-111496) (GH-111607) 2023-11-01 18:23:39 +00:00
code.c [3.12] C API tests: use special markers to test that output parameters were set (GH-109014) (#109023) 2023-09-08 15:09:49 +02:00
codec.c [3.12] gh-111495: add stub files for C API test modules (GH-111586) (GH-111592) 2023-11-01 09:43:56 +02:00
complex.c [3.12] gh-109802: Increase test coverage for complexobject.c (GH-112452) (GH-112489) 2023-11-28 08:33:44 +00:00
datetime.c [3.12] bpo-36796: Clean the error handling in _testcapimodule.c (GH-13085) (GH-113132) 2023-12-14 19:39:57 +00:00
dict.c [3.12] gh-110549: Remove unused includes of <stddef.h> in _testcapi (GH-110552) (GH-110553) 2023-10-09 11:43:35 +00:00
docstring.c gh-93649: Split memory and docstring tests from _testcapimodule.c (#99517) 2022-11-16 14:09:10 +01:00
exceptions.c [3.12] gh-108082: C API: Add tests for PyErr_WriteUnraisable() (GH-111455) (GH-111507) 2023-10-30 17:36:00 +00:00
file.c [3.12] gh-111495: add stub files for C API test modules (GH-111586) (GH-111592) 2023-11-01 09:43:56 +02:00
float.c [3.12] gh-111495: Add tests for PyFloat C API (GH-111624) (GH-111752) 2023-11-05 10:01:31 +02:00
gc.c gh-93649: Split gc- and allocation tests from _testcapimodule.c (GH-104403) 2023-05-12 10:26:07 +01:00
getargs.c [3.12] gh-112438: Fix support of format units with the "e" prefix in nested tuples in PyArg_Parse (gh-112439) (GH-112460) 2023-11-27 17:57:30 +00:00
heaptype.c [3.12] gh-103968: PyType_FromMetaclass: Allow metaclasses with tp_new=NULL (GH-105386) (GH-105697) 2023-06-12 16:24:21 +00:00
heaptype_relative.c gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511) 2023-05-04 09:56:53 +02:00
immortal.c Trim trailing whitespace and test on CI (#104275) 2023-05-08 17:03:52 +03:00
list.c [3.12] gh-111495: Add tests for PyList C API (GH-111562) (GH-111861) 2023-11-08 18:10:13 +00:00
long.c [3.12] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070) 2024-03-20 16:44:05 +02:00
mem.c [3.12] gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601) (#116929) 2024-03-18 10:22:19 +01:00
numbers.c [3.12] gh-111495: add stub files for C API test modules (GH-111586) (GH-111592) 2023-11-01 09:43:56 +02:00
parts.h [3.12] gh-117968: Add tests for the part of the PyRun family of the C API (GH-117982) (GH-118011) 2024-04-22 18:59:28 +00:00
pyos.c GH-94808: Cover PyOS_mystrnicmp and PyOS_mystricmp (gh-102469) 2023-03-22 20:35:27 +09:00
pytime.c gh-93649: Split pytime and datetime tests from _testcapimodule.c (#99494) 2022-11-15 08:17:52 +01:00
README.txt gh-104469: Update README.txt for _testcapi (gh-104529) 2023-05-17 12:56:20 +09:00
run.c [3.12] gh-117968: Make the test for closed file more safe in the C API tests (GH-118230) (GH-118266) 2024-04-25 05:16:43 +00:00
set.c [3.12] gh-110549: Remove unused includes of <stddef.h> in _testcapi (GH-110552) (GH-110553) 2023-10-09 11:43:35 +00:00
structmember.c [3.12] gh-47146: Fix reference counting in _testcapi.structmember initializer (GH-106862) (GH-106953) 2023-07-21 14:48:50 +03:00
sys.c [3.12] gh-111065: Add more tests for the C API with the PySys_ prefix (GH-111067) (GH-111305) 2023-10-25 09:10:03 +00:00
testcapi_long.h gh-93649: Split float/long tests from _testcapimodule.c (GH-99549) 2022-11-17 00:56:56 -08:00
tuple.c [3.12] gh-111495: add stub files for C API test modules (GH-111586) (GH-111592) 2023-11-01 09:43:56 +02:00
unicode.c [3.12] C API tests: use special markers to test that output parameters were set (GH-109014) (#109023) 2023-09-08 15:09:49 +02:00
util.h [3.12] gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533) (#109558) 2023-10-02 16:59:43 +02:00
vectorcall.c gh-99300: Use Py_NewRef() in Modules/ directory (#99440) 2022-11-13 16:04:33 +01:00
vectorcall_limited.c gh-98586: Add vector call APIs to the Limited API (GH-98587) 2022-10-27 11:45:42 +02:00
watchers.c [3.12] gh-91054: make code watcher tests resilient to other watchers (GH-107821) (#107835) 2023-08-11 16:13:14 +02:00

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.