Skip to content

gh-109721: Guard _testinternalcapi imports in tests #109722

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

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Sep 22, 2023

Why?

  1. test_cmd_line.py only imports it without a guard in check_pythonmalloc, which is only used in test_pythonmalloc, so marking it as @cpython_only is good enoug
  2. test_import/__init__.py already has several guards like requires_singlephase_init which implies @cpython_only, so only a except ImportError is needed
  3. test_opcache can be skipped without _testinternalcapi, because most (all?) tests are cpython-only and require it

@sobolevn sobolevn requested review from gvanrossum and removed request for brettcannon, warsaw, ncoghlan and ericsnowcurrently September 22, 2023 12:13
@AlexWaygood AlexWaygood changed the title gh-109721: Guard _testinernalcapi imports in tests gh-109721: Guard _testinternalcapi imports in tests Sep 22, 2023
@sobolevn
Copy link
Member Author

sobolevn commented Sep 22, 2023

This failure:

AssertionError: 'test_regrtest_huntrleaks leaked [1, 1, 1] references, sum=3\n' not found in '0:00:00 Run 1 test sequentially\n0:00:00 [1/1] test_regrtest_huntrleaks\nbeginning 6 repetitions\n123456\n......\ntest_regrtest_huntrleaks leaked [1, 9, 1] references, sum=11\ntest_regrtest_huntrleaks leaked [1, 1, 1] memory blocks, sum=3\ntest_regrtest_huntrleaks failed (reference leak)\n\n== Tests result: FAILURE ==\n\n1 test failed:\n    test_regrtest_huntrleaks\n\nTotal duration: 321 ms\nTotal tests: run=1\nTotal test files: run=1/1 failed=1\nResult: FAILURE\n'

does not seem related. Or is it? 🤔

@sobolevn
Copy link
Member Author

It is related, because this test uses def check_leak which is decorated as @without_optimizer, which uses _testinternalcapi inside.

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

@brettcannon brettcannon merged commit 8ded34a into python:main Sep 22, 2023
csm10495 pushed a commit to csm10495/cpython that referenced this pull request Sep 28, 2023
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
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.

3 participants