File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,3 @@ filterwarnings =
20
20
# bogus numpy ABI warning (see numpy/#432)
21
21
ignore:.*numpy.dtype size changed.*:RuntimeWarning
22
22
ignore:.*numpy.ufunc size changed.*:RuntimeWarning
23
- default:The global interpreter lock:RuntimeWarning
Original file line number Diff line number Diff line change 2
2
3
3
from __future__ import annotations
4
4
5
- import exo_planet_c_api
6
- import exo_planet_pybind11
7
- import home_planet_very_lonely_traveler
5
+ import importlib
6
+ import sys
7
+
8
8
import pytest
9
9
10
10
import env
11
11
from pybind11_tests import cpp_conduit as home_planet
12
12
13
13
14
+ def import_warns_freethreaded (name ):
15
+ if name not in sys .modules and not getattr (sys , "_is_gil_enabled" , lambda : True )():
16
+ with pytest .warns (
17
+ RuntimeWarning , match = f"has been enabled to load module '{ name } '"
18
+ ):
19
+ return importlib .import_module (name )
20
+
21
+ return importlib .import_module (name )
22
+
23
+
24
+ exo_planet_c_api = import_warns_freethreaded ("exo_planet_c_api" )
25
+ exo_planet_pybind11 = import_warns_freethreaded ("exo_planet_pybind11" )
26
+ home_planet_very_lonely_traveler = import_warns_freethreaded (
27
+ "home_planet_very_lonely_traveler"
28
+ )
29
+
30
+
14
31
def test_traveler_getattr_actually_exists ():
15
32
t_h = home_planet .Traveler ("home" )
16
33
assert t_h .any_name == "Traveler GetAttr: any_name luggage: home"
You can’t perform that action at this time.
0 commit comments