MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_missing_header_message

Function test_missing_header_message

tests/test_stl.py:412–430  ·  view source on GitHub ↗

Trying convert `list` to a `std::vector`, or vice versa, without including should result in a helpful suggestion in the error message

()

Source from the content-addressed store, hash-verified

410
411
412def 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
433def test_function_with_string_and_vector_string_arg():

Callers

nothing calls this directly

Calls 1

strClass · 0.85

Tested by

no test coverage detected