41#include <pybind11/embed.h>
42#include <pybind11/eval.h>
43#include <pybind11/pybind11.h>
94 data()[name.c_str()] = arr;
106 data()[name.c_str()] = val;
119 inline bool exec(
const char (&expr)[N], pybind11::object &&global = pybind11::globals()) {
121 py::exec(expr, std::forward<pybind11::object>(global),
locals);
122 }
catch (
const std::exception &e) {
123 logger::warn_ln(
"PyScriptHandle",
"the script throwed an error :", e.what());
Class allowing use of python scripts within a test case.
bool exec(const char(&expr)[N], pybind11::object &&global=pybind11::globals())
execute the given script
pybind11::dict & data()
return reference to the locals
void register_value(std::string name, T val)
register a value in a local py variable
void register_array(std::string name, std::vector< T > &arr)
register an array in a local py variable
pybind11::dict locals
local python variables
PyScriptHandle()
Construct PyScriptHandle and create an instance of PyScriptHandle::locals.