Skip to content

test_embed: four InitConfigTests tests are always skipped #161270

Closed

Description

@NekoAsakura

Bug report

cpython/Lib/test/test_embed.py

Lines 1113 to 1114 in 069aac9

@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries")
def test_init_default_config(self):

cpython/Lib/test/test_embed.py

Lines 1201 to 1202 in 069aac9

@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries")
def test_init_compat_env(self):

cpython/Lib/test/test_embed.py

Lines 1237 to 1238 in 069aac9

@unittest.skipIf(support.check_bolt_optimized, "segfaults on BOLT instrumented binaries")
def test_init_python_env(self):

cpython/Lib/test/test_embed.py

Lines 1962 to 1963 in 069aac9

@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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Nov 3, 2026
  2. gvanrossum commented on Nov 3, 2026

    @gvanrossum
    Member

    Good catch. Can you submit a PR? Have you found other, similar cases that could be fixed similarly?

  3. self-assigned this
    on Nov 3, 2026
  4. NekoAsakura commented on Nov 3, 2026

    @NekoAsakura
    MemberAuthor

    Will do. I did an AST scan for uncalled functions in skipIf/skipUnless, and this is the only one.

  5. vstinner commented on Nov 3, 2026

    @vstinner
    Member

    Maybe skipIf() and skipUnless() of unittest should raise an assertion error if condition is a function?

  6. NekoAsakura commented on Nov 3, 2026

    @NekoAsakura
    MemberAuthor

    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.

  7. vstinner commented on Nov 4, 2026

    @vstinner
    Member

    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.

  8. added 3 commits that reference this issue on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

easytestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions