mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
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() Add Modules/_testlimitedcapi/file.c file. Remove test_embed.StdPrinterTests which became redundant.
This commit is contained in:
parent
4e47e05045
commit
4ca9fc08f8
11 changed files with 500 additions and 72 deletions
|
@ -5,11 +5,29 @@
|
|||
#include "util.h"
|
||||
#include "clinic/file.c.h"
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
module _testcapi
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.pyfile_newstdprinter
|
||||
|
||||
fd: int
|
||||
/
|
||||
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyfile_newstdprinter_impl(PyObject *module, int fd)
|
||||
/*[clinic end generated code: output=8a2d1c57b6892db3 input=442f1824142262ea]*/
|
||||
{
|
||||
return PyFile_NewStdPrinter(fd);
|
||||
}
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.py_fopen
|
||||
|
||||
|
@ -38,7 +56,9 @@ _testcapi_py_fopen_impl(PyObject *module, PyObject *path, const char *mode,
|
|||
return PyBytes_FromStringAndSize(buffer, size);
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef test_methods[] = {
|
||||
_TESTCAPI_PYFILE_NEWSTDPRINTER_METHODDEF
|
||||
_TESTCAPI_PY_FOPEN_METHODDEF
|
||||
{NULL},
|
||||
};
|
||||
|
@ -46,9 +66,5 @@ static PyMethodDef test_methods[] = {
|
|||
int
|
||||
_PyTestCapi_Init_File(PyObject *m)
|
||||
{
|
||||
if (PyModule_AddFunctions(m, test_methods) < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return PyModule_AddFunctions(m, test_methods);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue