Repository navigation
Open
Labels
easytestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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:
cpython/Lib/test/support/__init__.py
Lines 1059 to 1065 in 069aac9
| 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
Metadata
Metadata
Assignees
Labels
easytestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
gvanrossum commentedon Nov 3, 2026
Good catch. Can you submit a PR? Have you found other, similar cases that could be fixed similarly?
NekoAsakura commentedon Nov 3, 2026
Will do. I did an AST scan for uncalled functions in
skipIf/skipUnless, and this is the only one.vstinner commentedon Nov 3, 2026
Maybe skipIf() and skipUnless() of unittest should raise an assertion error if condition is a function?
NekoAsakura commentedon Nov 3, 2026
I'd rather leave this to a linter than a runtime assert. The latter changes the public API, and may reject code like:
cpython/Lib/test/test__locale.py
Lines 3 to 6 in 7e3290d
cpython/Lib/test/test__locale.py
Line 144 in 7e3290d
where the condition is a callable on purpose to check availability.
vstinner commentedon Nov 4, 2026
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_threadsdecorator 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_threadsto detect when it's used on a class.