← 返回首页
GH-94808: Cover `PyOS_mystrnicmp` and `PyOS_mystricmp` by artemmukhin · Pull Request #102469 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

GH-94808: Cover PyOS_mystrnicmp and PyOS_mystricmp#102469

Merged
corona10 merged 3 commits into
python:mainfrom
artemmukhin:cover-pystrcmp
Mar 22, 2023
Merged

GH-94808: Cover PyOS_mystrnicmp and PyOS_mystricmp#102469
corona10 merged 3 commits into
python:mainfrom
artemmukhin:cover-pystrcmp

Conversation

artemmukhin commented Mar 6, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

ghost commented Mar 6, 2023
edited by ghost
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copy link
Copy Markdown
Contributor Author

I'm not sure who is best positioned to review this, but maybe @corona10 could take a look?

corona10 self-requested a review March 10, 2023 15:05

Copy link
Copy Markdown
Member

I'm not sure who is best positioned to review this, but maybe @corona10 could take a look?

Okay, I will take a look by this weekend :)

corona10 self-assigned this Mar 10, 2023

Copy link
Copy Markdown
Contributor Author

@corona10 Thank you!

corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Would you like to separate the file into Modules/_testcapi/pyos.c
likewise https://github.com/python/cpython/blob/main/Modules/_testcapi/float.c ?

The test itself looks good.

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

artemmukhin requested a review from a team as a code owner March 11, 2023 15:56

artemmukhin commented Mar 11, 2023
edited
Loading

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@corona10 Thank you for the review! I've separated the tests.

Although I haven't managed to run the tests from Modules/_testcapi on my machine. Before separating, I ran my tests via ./python -m test -v test_capi, but now they are not executed as I see. I found the C API Tests paragraph in the devguide, but I didn't find how to run these tests. Could you please clarify?

Copy link
Copy Markdown

Thanks for making the requested changes!

@corona10: please review the changes made to this pull request.

bedevere-bot requested a review from corona10 March 11, 2023 16:08

Copy link
Copy Markdown
Contributor Author

I've found out that the tests were not executed because of the wrong naming.

Test_testcapi only executes the test method if its built-in name starts with test_ and doesn't end with _code:

class Test_testcapi(unittest.TestCase):
locals().update((name, getattr(_testcapi, name))
for name in dir(_testcapi)
if name.startswith('test_') and not name.endswith('_code'))

It is mentioned in the C API Tests paragraph to some extent:

Functions named test_* are used as tests directly

But at first reading, I got confused because in _testcapi/float.c file, the test_ prefix is only used in the C function name:

static PyMethodDef test_methods[] = {
{"float_pack", test_float_pack, METH_VARARGS, NULL},
{"float_unpack", test_float_unpack, METH_VARARGS, NULL},
{NULL},
};

However, in contrast to my tests, these test methods are actually executed through test_float.py:

cpython/Lib/test/test_float.py

Lines 1516 to 1519 in 534660f

class PackTests(unittest.TestCase):
def test_pack(self):
self.assertEqual(_testcapi.float_pack(2, 1.5, BIG_ENDIAN),
b'>\x00')

I hope this investigation might help other first-time contributors.

@corona10 If you think it would be helpful to clarify this point in the devguide, please let me know, and I'll be happy to open a corresponding PR.

Copy link
Copy Markdown
Member

I've found out that the tests were not executed because of the wrong naming.
Test_testcapi only executes the test method if its built-in name starts with test_ and doesn't end with _code:
But at first reading, I got confused because in testcapi/float.c file, the test prefix is only used in the C function name:
However, in contrast to my tests, these test methods are actually executed through test_float.py:

AFAIK, those things are intended.

corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

LGTM

But I want to listen to the opinion of @erlend-aasland for this testing structure.

Copy link
Copy Markdown
Contributor Author

@erlend-aasland could you please take a look?

Copy link
Copy Markdown
Contributor Author

Thank you!

Cc @corona10

corona10 merged commit 0a60dea into python:main Mar 22, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
artemmukhin deleted the cover-pystrcmp branch April 2, 2023 22:17
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Footer

© 2026 GitHub, Inc.