GeezerVison is showing github.com — test_embed: four `InitConfigTests` tests are always skipped · Issue #161270 · python/cpython
test_embed: four InitConfigTests tests are always skipped #161270DescriptionBug report
|
@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries") |
|
def test_init_default_config(self): |
|
@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries") |
|
def test_init_compat_env(self): |
|
@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries") |
|
def test_init_python_env(self): |
|
@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries") |
|
def test_initconfig_api(self): |
support.check_bolt_optimized is a function:
|
def check_bolt_optimized(): |
|
# Always return false, if the platform is WASI, |
|
# because BOLT optimization does not support WASM binary. |
|
if is_wasi: |
|
return False |
|
config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' |
|
return '--enable-bolt' in config_args |
skipIf gets the function itself, which is always true as it defines neither __bool__ nor __len__, so these four tests are skipped on every build since #128474.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Activitygvanrossum commented on Nov 3, 2026 Good catch. Can you submit a PR? Have you found other, similar cases that could be fixed similarly? NekoAsakura commented on Nov 3, 2026 Will do. I did an AST scan for uncalled functions in skipIf/skipUnless, and this is the only one. vstinner commented on Nov 3, 2026 Maybe skipIf() and skipUnless() of unittest should raise an assertion error if condition is a function? NekoAsakura commented on Nov 3, 2026
Maybe skipIf() and skipUnless() of unittest should raise an assertion error if condition is a function?
I'd rather leave this to a linter than a runtime assert. The latter changes the public API, and may reject code like:
|
try: |
|
from _locale import (RADIXCHAR, THOUSEP, nl_langinfo) |
|
except ImportError: |
|
nl_langinfo = None |
|
@unittest.skipUnless(nl_langinfo, "nl_langinfo is not available") |
where the condition is a callable on purpose to check availability. Reacted by Guido van Rossum vstinner commented on Nov 4, 2026
The latter changes the public API, and may reject code like: (...)
Crap. I should have expected that it's never so easy to change a public API :-(
So well, it's uneasy to have a generic check to detect when skipIf() / skipUnless() is misused.
Recently, I fixed a similar issue with @reap_threads decorator which was used on a test case class, whereas the decorator doesn't support classes. So tests were always skipped: commit 565f76f / PR gh-158937. In that case, I was able to add a check to @reap_threads to detect when it's used on a class.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|