Skip to content

gh-110529: Guard _testcapi imports in tests #110530

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/test/test_capi/test_abstract.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
from collections import OrderedDict
import _testcapi
from test.support import import_helper

_testcapi = import_helper.import_module('_testcapi')
Copy link
Member

Choose a reason for hiding this comment

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

I think that such check should be done in Lib/test/test_capi/__init__.py. I don't think that it's worth to attempt to run any of sub-tests if _testcapi cannot be imported.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't agree that it should only be done there, because people can run only a single test file. In case of ./python.exe Lib/test/test_capi/test_WHATEVER.py, this test must also be skipped correctly.

However, I think that we can also check this in test_capi/__init__.py just to speed up test runs without _testcapi



NULL = None
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_capi/test_dict.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import unittest
from collections import OrderedDict, UserDict
from types import MappingProxyType
import _testcapi
from test.support import import_helper

_testcapi = import_helper.import_module('_testcapi')


NULL = None
Expand Down
Loading