Skip to content

Commit 31b3868

Browse files
committed
Add test_report_builtins_internals_keys
1 parent 4062387 commit 31b3868

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_gil_scoped.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
import builtins
12
import multiprocessing
23
import threading
34

5+
import pytest
6+
47
from pybind11_tests import gil_scoped as m
58

69

10+
def get_pybind11_internals_keys():
11+
keys = []
12+
for key in sorted(dir(builtins)):
13+
if key.startswith("__pybind11_internals_"):
14+
assert key.endswith("__")
15+
keys.append(key)
16+
return tuple(keys)
17+
18+
719
def _run_in_process(target, *args, **kwargs):
820
"""Runs target in process and returns its exitcode after 10s (None if still alive)."""
921
process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
@@ -110,6 +122,14 @@ def test_cross_module_gil_acquired():
110122
m.test_cross_module_gil_acquired() # Should not raise a SIGSEGV
111123

112124

125+
def test_report_builtins_internals_keys():
126+
"""For reporting, not an actual test."""
127+
m.test_cross_module_gil_released() # Any test that imports cross_module_gil_utils
128+
keys = get_pybind11_internals_keys()
129+
assert len(keys) != 0
130+
pytest.skip("builtins internals keys: %s" % ", ".join(keys))
131+
132+
113133
def test_cross_module_gil_inner_custom_released():
114134
"""Makes sure that the GIL can be acquired/released by another module
115135
from a GIL-released state using custom locking logic."""

0 commit comments

Comments
 (0)