Trying convert `list` to a `std::vector`, or vice versa, without including should result in a helpful suggestion in the error message
()
| 410 | |
| 411 | |
| 412 | def test_missing_header_message(): |
| 413 | """Trying convert `list` to a `std::vector`, or vice versa, without including |
| 414 | <pybind11/stl.h> should result in a helpful suggestion in the error message""" |
| 415 | import pybind11_cross_module_tests as cm |
| 416 | |
| 417 | expected_message = ( |
| 418 | "Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,\n" |
| 419 | "<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic\n" |
| 420 | "conversions are optional and require extra headers to be included\n" |
| 421 | "when compiling your pybind11 module." |
| 422 | ) |
| 423 | |
| 424 | with pytest.raises(TypeError) as excinfo: |
| 425 | cm.missing_header_arg([1.0, 2.0, 3.0]) |
| 426 | assert expected_message in str(excinfo.value) |
| 427 | |
| 428 | with pytest.raises(TypeError) as excinfo: |
| 429 | cm.missing_header_return() |
| 430 | assert expected_message in str(excinfo.value) |
| 431 | |
| 432 | |
| 433 | def test_function_with_string_and_vector_string_arg(): |