File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,10 @@ TEST_SUBMODULE(class_, m) {
137
137
struct Invalid {};
138
138
139
139
// test_type
140
- m.def (" check_type" , [](bool valid) {
141
- if (valid)
140
+ m.def (" check_type" , [](int category) {
141
+ if (category == 2 )
142
+ return py::type<int >();
143
+ else if (category == 1 )
142
144
return py::type<DerivedClass1>();
143
145
else
144
146
return py::type<Invalid>();
Original file line number Diff line number Diff line change @@ -25,9 +25,18 @@ def test_instance(msg):
25
25
26
26
27
27
def test_type ():
28
- assert m .check_type (True ) == m .DerivedClass1
29
- with pytest .raises (RuntimeError ):
30
- m .check_type (False )
28
+ assert m .check_type (1 ) == m .DerivedClass1
29
+ with pytest .raises (RuntimeError ) as execinfo :
30
+ m .check_type (0 )
31
+
32
+ assert 'pybind11::detail::get_type_info: unable to find type info' in str (execinfo .value )
33
+ assert 'Invalid' in str (execinfo .value )
34
+
35
+ with pytest .raises (RuntimeError ) as execinfo :
36
+ assert m .check_type (2 ) == int
37
+
38
+ assert 'pybind11::detail::get_type_info: unable to find type info' in str (execinfo .value )
39
+ assert 'int' in str (execinfo .value )
31
40
32
41
33
42
def test_docstrings (doc ):
You can’t perform that action at this time.
0 commit comments