mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
tests: expect free-threaded import warnings (#5680)
* tests: expect free-threaded import warnings Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update tests/test_cpp_conduit.py Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> * Update tests/test_cpp_conduit.py --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
This commit is contained in:
@@ -20,4 +20,3 @@ filterwarnings =
|
||||
# bogus numpy ABI warning (see numpy/#432)
|
||||
ignore:.*numpy.dtype size changed.*:RuntimeWarning
|
||||
ignore:.*numpy.ufunc size changed.*:RuntimeWarning
|
||||
default:The global interpreter lock:RuntimeWarning
|
||||
|
||||
@@ -2,15 +2,32 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import exo_planet_c_api
|
||||
import exo_planet_pybind11
|
||||
import home_planet_very_lonely_traveler
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
import env
|
||||
from pybind11_tests import cpp_conduit as home_planet
|
||||
|
||||
|
||||
def import_warns_freethreaded(name):
|
||||
if name not in sys.modules and not getattr(sys, "_is_gil_enabled", lambda: True)():
|
||||
with pytest.warns(
|
||||
RuntimeWarning, match=f"has been enabled to load module '{name}'"
|
||||
):
|
||||
return importlib.import_module(name)
|
||||
|
||||
return importlib.import_module(name)
|
||||
|
||||
|
||||
exo_planet_c_api = import_warns_freethreaded("exo_planet_c_api")
|
||||
exo_planet_pybind11 = import_warns_freethreaded("exo_planet_pybind11")
|
||||
home_planet_very_lonely_traveler = import_warns_freethreaded(
|
||||
"home_planet_very_lonely_traveler"
|
||||
)
|
||||
|
||||
|
||||
def test_traveler_getattr_actually_exists():
|
||||
t_h = home_planet.Traveler("home")
|
||||
assert t_h.any_name == "Traveler GetAttr: any_name luggage: home"
|
||||
|
||||
Reference in New Issue
Block a user