16 py::module m_sub = m.def_submodule(
"subsubmodule");
17 m_sub.def(
"submodule_func", []() {
return "submodule_func()"; });
32 .def(
"__repr__", &A::toString);
40 A &get_a1() {
return a1; }
41 A &get_a2() {
return a2; }
48 .def(
"get_a1", &B::get_a1,
"Return the internal A 1", py::return_value_policy::reference_internal)
49 .
def(
"get_a2", &B::get_a2,
"Return the internal A 2", py::return_value_policy::reference_internal)
53 m.
attr(
"OD") = py::module::import(
"collections").
attr(
"OrderedDict");
57 m.def(
"duplicate_registration", []() {
61 class DupeException { };
68 dm.
def(
"dupe1_factory", []() {
return Dupe1(); });
73 failures.append(
"Dupe1 class");
74 }
catch (std::runtime_error &) {}
76 dm.def(
"Dupe1", []() {
return Dupe1(); });
77 failures.append(
"Dupe1 function");
78 }
catch (std::runtime_error &) {}
81 failures.append(
"dupe1_factory");
82 }
catch (std::runtime_error &) {}
85 failures.append(
"Dupe2");
86 }
catch (std::runtime_error &) {}
88 dm.def(
"DupeException", []() {
return 30; });
89 failures.append(
"DupeException1");
90 }
catch (std::runtime_error &) {}
93 failures.append(
"DupeException2");
94 }
catch (std::runtime_error &) {}
void print_destroyed(T *inst, Values &&...values)
void print_copy_assigned(T *inst, Values &&...values)
void print_copy_created(T *inst, Values &&...values)
Wrapper for Python extension modules.
obj_attr_accessor attr(handle key) const
void print_default_created(T *inst, Values &&...values)
test_initializer modules("modules", test_submodule_modules)
void print_created(T *inst, Values &&...values)
#define TEST_SUBMODULE(name, variable)
bool typename Extra class_ & def(const char *name_, Func &&f, const Extra &... extra)
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)
class_ & def_readwrite(const char *name, D C::*pm, const Extra &... extra)