Skip to content

Add more C API tests #111495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
10 tasks done
serhiy-storchaka opened this issue Oct 30, 2023 · 18 comments
Closed
10 tasks done

Add more C API tests #111495

serhiy-storchaka opened this issue Oct 30, 2023 · 18 comments
Assignees
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes tests Tests in the Lib/test dir topic-C-API

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Oct 30, 2023

  • Add tests for PyBytes C API
  • Add tests for PyByteArray C API
  • Add tests for PyFloat C API
  • Add tests for PyComplex C API
  • Add tests for PyLong C API
  • Add tests for PyNumber C API
  • Add tests for PyTuple C API
  • Add tests for PyList C API
  • Add tests for PyCodec C API
  • Add tests for PyFile C API

Linked PRs

@serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir topic-C-API 3.12 only security fixes 3.13 bugs and security fixes labels Oct 30, 2023
@serhiy-storchaka serhiy-storchaka self-assigned this Oct 30, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Oct 30, 2023
@skirpichev
Copy link
Member

@serhiy-storchaka, initial set of C API tests for PyComplex (only for changed functions) was added in #109647

@serhiy-storchaka
Copy link
Member Author

Yes, there are also some tests for PyLong and PyNumber, and maybe other parts of the C API. But we should test the full C API, or at least document what is not tested. And it is better to group tests by the prefix, so it is clear where to find tests.

@serhiy-storchaka
Copy link
Member Author

If you want to work on adding tests to the part of the C API, say it here to avoid duplicating the work of other people. I finished work on PyBytes and PyByteArray and am not currently working on any of the above.

@skirpichev
Copy link
Member

@serhiy-storchaka, I will factor out tests PyComplex_RealAsDouble/ImagAsDouble from #109647 and tests for other functions for PyComplexType. (BTW, in #111496 I don't see actual tests, only interfaces. Tests in my pr were modeled from pack/unpack tests in test_float.py.)

@serhiy-storchaka
Copy link
Member Author

Good catch, @skirpichev. I forgot to add the actual test files.

@rawwar
Copy link
Contributor

rawwar commented Oct 31, 2023

@serhiy-storchaka , I would like to contribute tests to PyTuple and PyList C API

@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka , I would like to contribute tests to PyTuple and PyList C API

Great. Look at existing PySequence tests in Lib/test/test_capi/test_abstract.py. Some PyTuple and PyList tests can be a copy of PySequence tests. Look also at PyDict and PySet tests.

@skirpichev
Copy link
Member

skirpichev commented Nov 1, 2023

With multiple prs, Modules/Setup.stdlib.in will produce merge conflicts. (I already have fixed this a lot in #109647.) I will create a pr to add stub files for testing modules.

Edit:
#111586 - stub files for test modules
#111591 - tests for PyComplex C API on top of #111586

Then I'll add missing tests for PyFloat's C API.

skirpichev added a commit to skirpichev/cpython that referenced this issue Nov 1, 2023
This is to reduce merge conflicts (Modules/Setup.stdlib.in) for
subsequent pull requests for the issue.
skirpichev added a commit to skirpichev/cpython that referenced this issue Nov 1, 2023
This is to reduce merge conflicts (Modules/Setup.stdlib.in) for
subsequent pull requests for the issue.
skirpichev added a commit to skirpichev/cpython that referenced this issue Nov 1, 2023
@serhiy-storchaka
Copy link
Member Author

I will create a pr to add stub files for testing modules.

Good idea!

serhiy-storchaka pushed a commit that referenced this issue Nov 1, 2023
This is to reduce merge conflicts (Modules/Setup.stdlib.in) for
subsequent pull requests for the issue.
skirpichev added a commit to skirpichev/cpython that referenced this issue Nov 1, 2023
skirpichev added a commit to skirpichev/cpython that referenced this issue Nov 1, 2023
…GH-111586)

This is to reduce merge conflicts (Modules/Setup.stdlib.in) for
subsequent pull requests for the issue.
(cherry picked from commit 33ed5fa)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
serhiy-storchaka pushed a commit that referenced this issue Nov 1, 2023
…H-111592)

This is to reduce merge conflicts (Modules/Setup.stdlib.in) for
subsequent pull requests for the issue.
(cherry picked from commit 33ed5fa)
@sobolevn
Copy link
Member

sobolevn commented Nov 1, 2023

I am working on PyFile_ tests.

Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Signed-off-by: kalyanr <kalyan.ben10@live.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this issue Sep 5, 2024
(cherry picked from commit dbc1752)

Co-authored-by: kalyanr <kalyan.ben10@live.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner pushed a commit that referenced this issue Sep 5, 2024
encukou pushed a commit that referenced this issue Nov 1, 2024
picnixz added a commit to picnixz/cpython that referenced this issue Dec 8, 2024
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
vstinner added a commit to vstinner/cpython that referenced this issue Jan 18, 2025
* Add Lib/test/test_capi/test_eval.py
* Add Modules/_testlimitedcapi/eval.c

(cherry picked from commit bf8b374)
vstinner added a commit to vstinner/cpython that referenced this issue Jan 18, 2025
vstinner added a commit that referenced this issue Jan 18, 2025
* gh-111495: Add more tests on PyEval C APIs (#122789)

* Add Lib/test/test_capi/test_eval.py
* Add Modules/_testlimitedcapi/eval.c

(cherry picked from commit bf8b374)

* gh-111495: Fix refleaks in test_capi.test_eval tests (#122851)

(cherry picked from commit b4a3160)
vstinner added a commit that referenced this issue Jan 19, 2025
…#129023)

* Add Lib/test/test_capi/test_eval.py
* Add Modules/_testlimitedcapi/eval.c

(cherry picked from commit bf8b374)

* gh-111495: Fix refleaks in test_capi.test_eval tests (#122851)

(cherry picked from commit b4a3160)
(cherry picked from commit 430ccbc)
vstinner added a commit to vstinner/cpython that referenced this issue Jan 29, 2025
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 now redundant test_embed.StdPrinterTests.
vstinner added a commit to vstinner/cpython that referenced this issue Jan 29, 2025
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 now redundant test_embed.StdPrinterTests.
vstinner added a commit that referenced this issue Jan 30, 2025
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.
vstinner added a commit to vstinner/cpython that referenced this issue Jan 30, 2025
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.

(cherry picked from commit 4ca9fc0)
@vstinner
Copy link
Member

@serhiy-storchaka: I added tests on the PyFile C API with #129449. It was the last checkbox. Can we close this issue now?

vstinner added a commit that referenced this issue Jan 30, 2025
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.

(cherry picked from commit 4ca9fc0)
vstinner added a commit that referenced this issue Jan 31, 2025
[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 4ca9fc0)
(cherry picked from commit 9a59a51)
@vstinner
Copy link
Member

vstinner commented Feb 6, 2025

I close the issue. A lot of work has been done in this issue!

If someone wants to continue this work, I suggest to open new issues such as #117968.

@vstinner vstinner closed this as completed Feb 6, 2025
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Feb 7, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes tests Tests in the Lib/test dir topic-C-API
Projects
None yet
Development

No branches or pull requests

6 participants