bpo-1635741: test_embed cheks that Python does not leak by vstinner · Pull Request #31555 · python/cpython

Choose a reason for hiding this comment

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

The test itself looks good to me (I suggested to use a test.support helper, if you want fewer lines), but EmbeddingTestsMixin (where this test lives) does not run at all on out-of-tree-builds (at least on my MacBook):

$ ./python.exe -m test test_embed -m test_no_memleak -v
Raised RLIMIT_NOFILE: 256 -> 1024
== CPython 3.11.0a5+ (heads/test_no_memleak-dirty:e6ca72c9e4, Feb 24 2022, 20:21:11) [Clang 13.0.0 (clang-1300.0.29.30)]
== macOS-12.2.1-x86_64-i386-64bit little-endian
== cwd: /Users/erlendaasland/src/cpython-build/build/test_python_68548æ
== CPU count: 16
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 1.87 Run tests sequentially
0:00:00 load avg: 1.87 [1/1] test_embed
test_no_memleak (test.test_embed.MiscTests) ... skipped "'/Users/erlendaasland/src/cpython-build/Programs/_testembed' doesn't exist"

EmbeddingTestsMixin is fenced out by its setUp function:

        if exepath != expecteddir or not os.path.exists(exe):
            self.skipTest("%r doesn't exist" % exe)

For OOT builds, exepath != expecteddir resolves to True and not os.path.exists(exe) resolves to False.

Hm, looks like this is a deliberate choice. See f4b1244 / GH-29063.